我正在尝试将此记录保存在Access数据库中,但是当我单击“保存”按钮时遇到以下错误:
"Data type mismatch in criteria expression" highlighting "dcProducts.ExecuteNonQuery"
代码:
conn.Open()
strProduct = "insert into Products_Table values('" & Val(txtProductID.Text) & _
"',' " & txtProductName.Text & _
"','" & cboUoM.Text & _
"','" & txtRemarks.Text & _
"','" & txtPrice.Text & "')"
dcProduct = New OleDbCommand(strProduct, conn)
dcProduct.ExecuteNonQuery()
For i = 0 To dgvRawMaterials.RowCount - 2
strRawMaterial = "insert into BillsofMaterials values('" & Val((dgvRawMaterials.Item(0, i).Value)) & _
"',' " & Val(dgvRawMaterials.Item(2, i).Value) & "')"
dcRawMaterial = New OleDbCommand(strRawMaterial, conn)
dcRawMaterial.ExecuteNonQuery()
Next