Save Image to MS Access database from PictureBox ERROR

  • Thread starter Thread starter kafsar
  • Start date Start date
K

kafsar

Guest
trying to save PictureBox image to MS Access database but received the following error:

Data type mismatch in criteria expression.


Dim ms As New MemoryStream

PictureBox1.Image.Save(ms, PictureBox1.Image.RawFormat)

Dim img() As Byte

img = ms.ToArray()

Dim updateQuery As String = "UPDATE Staff SET photo = @img WHERE sid = " & txtId.Text

Dim command As New OleDbCommand(updateQuery, MDBconn)
command.Parameters.Add("@img", OleDbType.Binary).Value = img

command.ExecuteNonQuery()

If save to SQL Server then no problem.

Dim ms As New MemoryStream

PictureBox1.Image.Save(ms, PictureBox1.Image.RawFormat)

Dim img() As Byte

img = ms.ToArray()

Dim updateQuery As String = "UPDATE Staff SET photo = @img WHERE sid = " & txtId.Text

Dim command As New SqlCommand(updateQuery, Conn)
command.Parameters.Add("@img", SqlDbType.Binary).Value = img

command.ExecuteNonQuery()
Where I am wrong with MS Access db?

Continue reading...
 
Back
Top