I'm calling dataadapter.update() but it says "System.Data.OleDb.OleDbException: 'Syntax error in INSERT INTO statement.'" but the insert statement was generated with an OleDbCommandBuilder so I can't figure out where the error actually is. This is where the dataadapter is built
Code:
Public Function Gettransaction_lines(Optional id As Long = -200) As DataTable
Dim query As String
Dim dt As New DataTable
query = "SELECT * FROM transaction_lines WHERE id=@id"
Dim conndb = New OleDbConnection(connStr)
Dim cmd = New OleDbCommand(query, conndb)
With cmd.Parameters
.Add("@id", OleDbType.BigInt).Value = id
End With
transaction_linesAdapter = New OleDbDataAdapter(query, conndb)
transaction_linesAdapter.SelectCommand = cmd
Dim cmdB = New OleDbCommandBuilder(transaction_linesAdapter)
transaction_linesAdapter.Fill(dt)
Return dt
End Function
this is where I get the table
Code:
dtNewtransaction_lines = Gettransaction_lines(-200)
-200 so I end up with the table structure but no actual rows
Then I create newrows with
Code:
transaction_linesNewRow = dtNewtransaction_lines.NewRow
Fill the row with data from use selections (no manual entry so no SQL injection possible) then add back to the table
Code:
dtNewtransaction_lines.Rows.Add(transaction_linesNewRow)
Then call the update that generates the error
Code:
transaction_linesAdapter.Update(dtNewtransaction_lines)
I don't see anything that could be wrong so it is probably a misleading error message and I am clueless. Any idea what I should try?