954,514 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Problem with byte to mysql

i try to put picture in mysql with vb.net, first i convert with this function :

Public Function convertImage(ByVal myImage As Image) As Byte()
        Dim mStream As New MemoryStream()
        myImage.Save(mStream, System.Drawing.Imaging.ImageFormat.Jpeg)
        Dim myBytes(mStream.Length = 1) As Byte
        mStream.Position = 0
        mStream.Read(myBytes, 0, mStream.Length)
        Return myBytes
    End Function


i try to use that function for storing picture to mysql database :

INSERT INTO myImage (image) VALUES ('" & convertImage(PictureBox1.image) & "');


and then i have this error :

Operator '&' is not defined for types 'String' and '1-dimensional array of Byte'


i create a table (myImage) with image field (LongBlob)

need your help with that error please!

artemix22
Light Poster
45 posts since Jan 2012
Reputation Points: 14
Solved Threads: 5
 

Can't speak to MYSQL but in SQL Server you insert the file directly as

insert into Pictures (name,picture) 
Values ('first pic',(select * from openrowset(bulk 'd:\temp\testpic.jpg',single_blob) as picture))

In this case my table is named Pictures and is defined as name=VARCHAR(50) and picture=VARBINARY(MAX)

The last parameter in the above example (picture) is the name of the column defined as VARBINARY(MAX)

Reverend Jim
Posting Shark
Moderator
1,167 posts since Aug 2010
Reputation Points: 253
Solved Threads: 159
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You