Click here to Skip to main content
15,075,944 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to knw how to upload images to mysql server through VB.net
Posted
Comments
[no name] 27-Nov-11 7:24am
   
google?

   
Comments
Mehdi Gholam 27-Nov-11 7:34am
   
OP : I dont want to Upload to SQL server i want to upload in MySql Server.... and i am not using ASP.net
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...
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900