我在使用此代码的表单中收到错误:
Private Sub btnCommit_Click(sender As Object, e As EventArgs) Handles btnCommit.Click
' Select Case MsgBox("Are you sure to Save this record?", MsgBoxStyle.YesNo, "Save")
'Case MsgBoxResult.Yes
row = maxRows
txtProductID.Text = CStr(row)
maxRows = maxRows + 1
txtProductID.Text = CStr(maxRows)
If row <> -1 Then
Dim cb As New OleDb.OleDbCommandBuilder(productAdapter)
Dim mynewrow As DataRow
mynewrow = productDataset.Tables("ProductTable").NewRow()
mynewrow.Item(0) = CInt(txtProductID.Text)
mynewrow.Item(1) = txtDescription.Text
mynewrow.Item(2) = txtSize.Text
mynewrow.Item(3) = txtQoh.Text
mynewrow.Item(4) = txtUnitPrice.Text
mynewrow.Item(5) = txtWarranty.Text
productDataset.Tables("ProductTable").Rows.Add(mynewrow)
productAdapter.Update(productDataset, "ProductTable")
MsgBox("Record added to database")
btnCommit.Hide()
btnAdd.Show()
btnUpdate.Show()
btnDelete.Show()
End If
' Case MsgBoxResult.No
' End Select
End Sub
错误发生在productAdapter.Update(productDataset, "ProductTable")
行,它说
“System.Data.OleDb.OleDbException”类型的未处理异常
发生在System.Data.dll。
我使用了另一种形式的相同代码,并且工作正常。
这里有什么问题?
异常详细信息:
{“INSERT INTO语句中的语法错误。”