我在更新MS Access数据库表时遇到标准表达式错误的数据类型不匹配。我知道'string'数据类型的单引号,因为我检查了有关此错误的类似问题。可以是因为图像是查询的一部分吗?
以下是代码:
Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles
btnSave.Click
Try
con = New OleDbConnection(cs)
con.Open()
Dim ms As New MemoryStream()
Dim bmpImage As New Bitmap(pbMyImage.Image)
bmpImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg)
Dim data As Byte() = ms.GetBuffer()
Dim p As New OleDbParameter("@image", OleDbType.VarBinary)
p.Value = data
Dim cb As String = "Update Members set IDPassNum = @IDPass and Firstname = @Fname and Lastname = @LName and Gender = @gender and Contact1 = @contact1 and Contact2 = @contact2 and City = @city and Address = @address and DoB = @dob and EmailID = @email and DOJ = @doj and Designation =@design and Status =@status and Photo = @image where TKBSNum = @tkbsnum"
cmd = New OleDbCommand(cb)
cmd.Connection = con
cmd.Parameters.Add("@IDPass", OleDbType.Char)
cmd.Parameters.Add("@Fname", OleDbType.Char)
cmd.Parameters.Add("@LName", OleDbType.Char)
cmd.Parameters.Add("@gender", OleDbType.Char)
cmd.Parameters.Add("@contact1", OleDbType.Char)
cmd.Parameters.Add("@contact2", OleDbType.Char)
cmd.Parameters.Add("@city", OleDbType.Char)
cmd.Parameters.Add("@address", OleDbType.Char)
cmd.Parameters.Add("@dob", OleDbType.Char)
cmd.Parameters.Add("@email", OleDbType.Char)
cmd.Parameters.Add("@doj", OleDbType.Char)
cmd.Parameters.Add("@design", OleDbType.Char)
cmd.Parameters.Add("@status", OleDbType.Char)
cmd.Parameters.Add("@tkbsnum", OleDbType.Char)
cmd.Parameters.Add(p)
cmd.ExecuteNonQuery()
MessageBox.Show("Successfully updated member details", " TKBS
Member Record", MessageBoxButtons.OK, MessageBoxIcon.Information)
con.Close()
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "ERROR5", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
这是数据库结构: