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!

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)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.