I'm wondering how to save image to MYSQL-DB via vb.net application. At the last I find some way to save image. But 'some type of images' doesn't save in that way. By 'some type of images' I mean diffrent widths,heights and resolutions.
For example I use this code to save image. On database there are two columns in table.
Dim mstream As New System.IO.MemoryStream()
propic.Image.Save(mstream, System.Drawing.Imaging.ImageFormat.Jpeg)
Dim arrImage() As Byte = mstream.GetBuffer()
mstream.Close()
query = "INSERT INTO client(client_id, pro_pic) VALUES(@client_id, @pro_pic)"
Dim cmd = New MySqlCommand(query, con)
cmd.Parameters.AddWithValue("@client_id", (TextBox1.Text))
cmd.Parameters.AddWithValue("@pro_pic", arrImage)
Try
con.Open()
cmd.ExecuteNonQuery()
MsgBox("Image Has Been Saved", "Save Picture")
Catch ex As Exception
MsgBox(ex.Message)
Exit Sub
End Try
If (con.State = ConnectionState.Open) Then
con.Close()
End If
when I use diffrent sizes widths,heights or resolution size images this occure error.
The error say : "Data too long for column 'pro_pic' at row 1"
Now I want to know about why this shows and how to get rid this.....