常规讨论 Syntax error in INSERT INTO statement.,OLEDBEXCEPTION

  • Monday, April 16, 2012 1:56 PM
     
     

    i am having trouble with the inserting of new values though the textboxes. it gives me the error Syntax error in INSERT INTO statement.,OLEDBEXCEPTION was unhandled at  --->  da.Update(ds,"Doc"). Whereas there is no such insert into statement in my code. 

    Below is my code for Ms-Access dbase:

     Private Sub btnCommit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCommit.Click
            Dim cb As New OleDb.OleDbCommandBuilder(da)
            Dim dsNewRow As DataRow

            dsNewRow = ds.Tables("Doc").NewRow()
            dsNewRow.Item("First Name") = First_NameTextBox.Text
            dsNewRow.Item("Surname") = Last_NameTextBox.Text
            ds.Tables("Doc").Rows.Add(dsNewRow)
            da.Update(ds, "Doc")
            MsgBox("New Record added to the Database")

            btnCommit.Enabled = False
            btnAddNew.Enabled = True
        End Sub

    • Changed Type HemangiL Monday, April 16, 2012 2:36 PM
    •  

All Replies