title: Update image in access database VB Net
body: <p>I got an error trying to update an image.</p>
  
  <p>This is the code I used to do that:</p>
  
  <p>Dim data() As Byte
          Dim ms As New IO.MemoryStream
          Dim i As Short</p>
  
  <pre><code>    Dim conn As New OleDbConnection
  
      conn = New OleDbConnection(kon)
  
      conn.Open()
  
      Dim sql As String = "UPDATE prop SET nmpr ='" &amp; TextBox1.Text &amp; "', peta = @peta where nmr ='" &amp; ComboBox1.Text &amp; "';"
  
      Try
          Dim cmd As New OleDbCommand(sql, conn)
          'cmd.Connection = conn
          'cmd.CommandType = CommandType.Text
  
          If PictureBox1 IsNot Nothing Then
              PictureBox1.Image.Save(ms, PictureBox1.Image.RawFormat)
              data = ms.GetBuffer
          Else
              PictureBox1.Image = Nothing
          End If
  
          cmd.Parameters.Add("@peta", OleDbType.Binary).Value = data
          i = cmd.ExecuteNonQuery
  
      Catch ex As Exception
  
          Dim Msg As String = "Unable to update"
  
          If ex IsNot Nothing Then
              Msg &amp;= ":" &amp; ControlChars.NewLine &amp; ControlChars.NewLine &amp; ex.ToString
          End If
  
          MessageBox.Show(Msg, My.Application.Info.AssemblyName, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1)
  
      End Try
  
      If (i &gt; 0) Then
          MessageBox.Show("Sukses")
      End If
  
      conn.Close()
  </code></pre>
  
  <p>The error says:</p>
  
  <blockquote>
    <p>datatype mismatch in criteria expresion</p>
  </blockquote>
  
  <p>i dont know which is mismatch, i just want to update image (peta) and nmpr field (texttbox.text)</p>