D
Dazz
Hello
I have made a small app to query a database which works fine. I am now
adding a logging function which writes back to the database in a separate
table. When I update the OleDataAdapter, I get an error saying "Syntax
error in INSERT INTO statement" but the insert statement was automatically
generated by OleDBCommandBuilder.
Can someone help me in finding the problem????
Thanks
Dazz
--------------------------------------------------------------
Dim SQLString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=Booking.mdb"
Dim daLogFile1 As New OleDbDataAdapter()
Dim dtLogFile1 As New DataTable()
Dim dc1 As New OleDb.OleDbConnection(SQLString)
Dim myRow1 As DataRow = dtLogFile1.NewRow
Dim cb1 As New OleDbCommandBuilder(daLogFile1)
'// The SQL statement generated is:
'// INSERT INTO SearchLog( LogNo , Date , Time , PostCode , Product ,
Status ) VALUES ( ? , ? , ? , ? , ? , ? )
'// Create the connection and fill datatable
daLogFile1.SelectCommand = New OleDb.OleDbCommand("SELECT * FROM SearchLog")
daLogFile1.SelectCommand.Connection = dc1
daLogFile1.Fill(dtLogFile1)
'// Create the data to be inserted
myRow1.Item("LogNo") = "000001"
myRow1.Item("Date") = Format(Now, "dd-MM-yyyy")
myRow1.Item("Time") = Format(Now, "HH:mm:ss")
myRow1.Item("PostCode") = txtSearchPC.Text
myRow1.Item("Product") = ""
myRow1.Item("Status") = "Query"
'// Add the completed row to the DataTable
dtLogFile1.Rows.Add(myRow1)
'// "Syntax error in INSERT INTO Statement" on this line
daLogFile1.Update(dtLogFile1)
dtLogFile1.AcceptChanges()
-------------------------------------------------------
I have made a small app to query a database which works fine. I am now
adding a logging function which writes back to the database in a separate
table. When I update the OleDataAdapter, I get an error saying "Syntax
error in INSERT INTO statement" but the insert statement was automatically
generated by OleDBCommandBuilder.
Can someone help me in finding the problem????
Thanks
Dazz
--------------------------------------------------------------
Dim SQLString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=Booking.mdb"
Dim daLogFile1 As New OleDbDataAdapter()
Dim dtLogFile1 As New DataTable()
Dim dc1 As New OleDb.OleDbConnection(SQLString)
Dim myRow1 As DataRow = dtLogFile1.NewRow
Dim cb1 As New OleDbCommandBuilder(daLogFile1)
'// The SQL statement generated is:
'// INSERT INTO SearchLog( LogNo , Date , Time , PostCode , Product ,
Status ) VALUES ( ? , ? , ? , ? , ? , ? )
'// Create the connection and fill datatable
daLogFile1.SelectCommand = New OleDb.OleDbCommand("SELECT * FROM SearchLog")
daLogFile1.SelectCommand.Connection = dc1
daLogFile1.Fill(dtLogFile1)
'// Create the data to be inserted
myRow1.Item("LogNo") = "000001"
myRow1.Item("Date") = Format(Now, "dd-MM-yyyy")
myRow1.Item("Time") = Format(Now, "HH:mm:ss")
myRow1.Item("PostCode") = txtSearchPC.Text
myRow1.Item("Product") = ""
myRow1.Item("Status") = "Query"
'// Add the completed row to the DataTable
dtLogFile1.Rows.Add(myRow1)
'// "Syntax error in INSERT INTO Statement" on this line
daLogFile1.Update(dtLogFile1)
dtLogFile1.AcceptChanges()
-------------------------------------------------------