Sub retrievepic()
Dim conn As New SqlConnection("data source=.\sqlexpress; integrated security=true; attachdbfilename=|datadirectory|\WAIS.mdf; user instance=true;")
Dim cmd As New SqlCommand("select ImageData from ImagesStore where ImageId=@ImageId", conn)
cmd.Parameters.AddWithValue("@ImageId", 3)
Try
conn.Open()
PictureBox1.Image = Image.FromStream(New IO.MemoryStream(CType(cmd.ExecuteScalar, Byte())))
Catch ex As Exception
MsgBox(ex.Message)
Finally
conn.Close()
End Try
End Sub
This is my code for retrieving pictures, it was working before but then i accidentally deleted the table and i created it again with the same name and same fields. and now whenever i open the form with the picture, there was a message box error. it says
Buffer cannot be null. Parameter name: buffer
I don't know what i did wrong.