使用VB.NET将图像上传到MySql服务器 [英] Upload Image to MySql server using VB.NET
本文介绍了使用VB.NET将图像上传到MySql服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道如何通过VB.net将图像上传到mysql服务器.
I want to knw how to upload images to mysql server through VB.net
推荐答案
尝试一下:
上传图像并将位置存储在数据库中
在ASP .NET中将图像插入到SqlServer中
Try this :
upload images and store the location in a database
Inserting Images to SqlServer in ASP .NET
试用
使用ASP.NET在MySQL中存储图像 [ http://csharpdotnetfreak.blogspot.com/2009/07/fileupload-control- save-images-database.html [ ^ ]
Try out
Storing Images in MySQL using ASP.NET[^]
http://csharpdotnetfreak.blogspot.com/2009/07/fileupload-control-save-images-database.html[^]
在一个模块中使用此功能..
< pre lang ="vb">
私有函数BytesToImage(以字节形式ByByVal ImageBytes()作为图像)
昏暗imgNew为图片
将memImage用作新System.IO.MemoryStream(ImageBytes)
imgNew = Image.FromStream(memImage)
返回imgNew
最终功能
私有函数ImageToBytes(按图像形式的ByVal图像)作为Byte()
将memImage用作新的System.IO.MemoryStream
按字节变暗bytImage()
Image.Save(memImage,Image.RawFormat)
bytImage = memImage.GetBuffer()
返回bytImage
最终功能
</pre>
然后将您的图像浏览到pictureBox....
并使用上述功能将其从图像字节转换为...
< pre lang ="vb">
昏暗的img2bite()作为字节= ImageToBytes(Picturebox1.image)
</pre>
并在查询参数中使用img2bite ...
但是您需要在SQL SERVER中将图像列的类型设置为图像" ...
希望你能得到...
User this functions in one module..
<pre lang="vb">
Private Function BytesToImage(ByVal ImageBytes() As Byte) As Image
Dim imgNew As Image
Dim memImage As New System.IO.MemoryStream(ImageBytes)
imgNew = Image.FromStream(memImage)
Return imgNew
End Function
Private Function ImageToBytes(ByVal Image As Image) As Byte()
Dim memImage As New System.IO.MemoryStream
Dim bytImage() As Byte
Image.Save(memImage, Image.RawFormat)
bytImage = memImage.GetBuffer()
Return bytImage
End Function
</pre>
then browse you image to pictureBox....
and use the above functions to convert it from image byte...
<pre lang="vb">
Dim img2bite() as byte = ImageToBytes(Picturebox1.image)
</pre>
and use img2bite in the parameter to your query...
but you need to make type of image column in SQL SERVER as "image"...
Hope you wil get...
这篇关于使用VB.NET将图像上传到MySql服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文