带有访问数据库的vb.net中update语句中的语法错误

时间:2016-06-03 16:03:14

标签: database vb.net access

抱歉,我多次尝试找出问题所在并且我什么也没找到,我得到的错误是“更新语句中的语法错误”。

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
    Dim pos As Integer = BindingContext(clientsDT).Position
    With clientsDT.Rows(pos)
        .Item("Client_ID") = Client_IDTextBox.Text
        .Item("Company_name") = Company_nameTextBox.Text
        .Item("Address") = AddressTextBox.Text
        .Item("City") = CityTextBox.Text
        .Item("Personnel") = PersonnelTextBox.Text
        .Item("Personnel_Gender") = Personnel_GenderComboBox.Text
        .Item("Personnel_Phone") = Personnel_PhoneTextBox.Text
        .Item("Client_Value") = Client_ValueTextBox.Text
        .Item("Client_Added by") = Added_byTextBox.Text
        .Item("Date_added") = Date_AddedDateTimePicker.Value
        .Item("Time_added") = Time_AddedDateTimePicker.Value
    End With
    Try
        Dim save As New OleDbCommandBuilder(clientsDA)
        clientsDA.Update(clientsDT)
        clientsDT.AcceptChanges()
        MsgBox("Data Saved Successfully")
        load_clients()
    Catch ex As Exception
        MessageBox.Show(ex.ToString)
    End Try
End Sub

每当我尝试操作数据库时,无论是通过更新还是添加新数据,我都会遇到此错误。 请找附件,我总是得到的错误 exception error

the second error

1 个答案:

答案 0 :(得分:0)

我会冒这样猜测它在这一行的字段名称中的空格:

.Item("Client_Added by") = Added_byTextBox.Text