I have this code but gives me an error on the insert statement. User selects image from file which loads into picturebox. I then pull out the image to store in SQL 2005.
I believe I am not formatting the itemImage variable in the insert line, but I need help. Maybe better to pull image from file rather then picturebox?
TIA
Code:
If have_image = True Then
Dim ms As New MemoryStream
PictureBox3.Image.Save(ms, PictureBox3.Image.RawFormat)
Dim itemImage() As Byte = ms.GetBuffer
ms.Close()
Dim cn2 As New SqlConnection(insert_conn_string)
Dim objCommand2 As New SqlCommand("", cn2)
cn2.Open()
objCommand2.CommandText = "INSERT INTO images(stored_image,image_guid) VALUES(itemImage,'" & strGUID & "')"
objCommand2.ExecuteNonQuery()
cn2.Close()
cn2 = Nothing
End If
I believe I am not formatting the itemImage variable in the insert line, but I need help. Maybe better to pull image from file rather then picturebox?
TIA