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!

5 Years
Discussion Span
Last Post by Reverend Jim

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)

Edited by Reverend Jim: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.