保存文件以访问数据库时“条件表达式中的数据类型不匹配”

时间:2014-02-27 15:42:20

标签: vb.net ms-access

我正在尝试将此记录保存在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

0 个答案:

没有答案