Hi everyone.
I am working on a project where user data is stored in sql db along with its image which is captured using a webcam.
I have finished the part where image is captured successfully and stored in picturebox, but the image from picturebox doesn't pass into the sql table, this part gives an error.
this is my code to insert picturebox image into sql database
Dim cmd As New SqlCommand("INSERT INTO detail4 VALUES(@tag,@pic)", sql)
cmd.Parameters.AddWithValue("@name", Button1.Text)
Dim ms As New MemoryStream()
PictureBox1.BackgroundImage.Save(ms, PictureBox1.BackgroundImage.RawFormat)
Dim data As Byte() = ms.GetBuffer()
Dim p As New SqlParameter("@photo", SqlDbType.Image)
p.Value = data
cmd.Parameters.Add(p)
cmd.ExecuteNonQuery()
MessageBox.Show("Name & Image has been saved", "Save",MessageBoxButtons.OK)
i get an error at
PictureBox1.BackgroundImage.Save(ms, PictureBox1.BackgroundImage.RawFormat)
is it because of rawformat... pls help...