I posted is some days ago but people miss it or they can´t help me.
Here is the problem:
When i try do commit changes or add a new record i get "Syntax error in INSERT INTO-expression"
the thing is i´ve used the same code to my test project ( but with less columns in the database )
and in the test project it works fine. there is the code for the "save / commit changes "
Private Sub ToolStripButton1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
If My.Settings.chang = True Then
Dim cb As New OleDb.OleDbCommandBuilder(da)
ds.Tables("Database2").Rows(inc).Item(1) = txtfm.Text
ds.Tables("Database2").Rows(inc).Item(2) = txtem.Text
ds.Tables("Database2").Rows(inc).Item(3) = txtga.Text
ds.Tables("Database2").Rows(inc).Item(4) = txtpn.Text
ds.Tables("Database2").Rows(inc).Item(5) = txts.Text
ds.Tables("Database2").Rows(inc).Item(6) = txttm.Text
ds.Tables("Database2").Rows(inc).Item(7) = txtth.Text
ds.Tables("Database2").Rows(inc).Item(8) = txtma.Text
ds.Tables("Database2").Rows(inc).Item(9) = txta1.Text
ds.Tables("Database2").Rows(inc).Item(10) = txtpc.Text
ds.Tables("Database2").Rows(inc).Item(11) = txtgf.Text
ds.Tables("Database2").Rows(inc).Item(12) = cmba.Text
ds.Tables("Database2").Rows(inc).Item(13) = txthd.Text
ds.Tables("Database2").Rows(inc).Item(14) = cmbmt.Text
ds.Tables("Database2").Rows(inc).Item(15) = cmbop.Text
ds.Tables("Database2").Rows(inc).Item(16) = cmbdl.Text
ds.Tables("Database2").Rows(inc).Item(17) = txtn.Text
ds.Tables("Database2").Rows(inc).Item(18) = txttmf.Text
ds.Tables("Database2").Rows(inc).Item(19) = txtthf.Text
ds.Tables("Database2").Rows(inc).Item(20) = txtgaf.Text
ds.Tables("Database2").Rows(inc).Item(21) = txtpnf.Text
ds.Tables("Database2").Rows(inc).Item(22) = txtsf.Text
ds.Tables("Database2").Rows(inc).Item(23) = txta2.Text
ds.Tables("Database2").Rows(inc).Item(24) = txtsb.Text
'ds.Tables("Database").Rows(inc).Item(25) = BindingNavigatorPositionItem.Text
ds.Tables("Database2").Rows(inc).Item(26) = txtp.Text
ds.Tables("Database2").Rows(inc).Item(27) = txtep.Text
da.Update(ds, "Database2")
MsgBox("Data updated")
ElseIf My.Settings.chang = False Then
If inc <> -1 Then
Dim cb As New OleDb.OleDbCommandBuilder(da)
Dim dsNewRow As DataRow
dsNewRow = ds.Tables("Database2").NewRow()
dsNewRow.Item(1) = txtfm.Text
dsNewRow.Item(2) = txtem.Text
dsNewRow.Item(3) = txtga.Text
dsNewRow.Item(4) = txtpn.Text
dsNewRow.Item(5) = txts.Text
dsNewRow.Item(6) = txttm.Text
dsNewRow.Item(7) = txtth.Text
dsNewRow.Item(8) = txtma.Text
dsNewRow.Item(9) = txta1.Text
dsNewRow.Item(10) = txtpc.Text
dsNewRow.Item(11) = txtgf.Text
dsNewRow.Item(12) = cmba.Text
dsNewRow.Item(13) = txthd.Text
dsNewRow.Item(14) = cmbmt.Text
dsNewRow.Item(15) = cmbop.Text
dsNewRow.Item(16) = cmbdl.Text
dsNewRow.Item(17) = txtn.Text
dsNewRow.Item(18) = txttmf.Text
dsNewRow.Item(19) = txtthf.Text
dsNewRow.Item(20) = txtgaf.Text
dsNewRow.Item(21) = txtpnf.Text
dsNewRow.Item(22) = txtsf.Text
dsNewRow.Item(23) = txta2.Text
dsNewRow.Item(24) = txtsb.Text
'dsNewRow.Item(25) = BindingNavigatorPositionItem.Text
dsNewRow.Item(26) = txtp.Text
dsNewRow.Item(27) = txtep.Text
ds.Tables("Database2").Rows.Add(dsNewRow)
da.Update(ds, "Database2")
MsgBox("New Record added to the Database")
My.Settings.chang = True
'btnCommit.Enabled = False
'btnAddNew.Enabled = True
'btnUpdate.Enabled = True
'btnDelete.Enabled = True
End If
End If
End Sub
Dim ds As New DataSet | Dim da As OleDb.OleDbDataAdapter
This post has been edited by EndLessMind: 02 February 2010 - 12:01 PM

New Topic/Question
Reply




MultiQuote







|