For some reason when I try to add a 3rd columns in my insert command I get the “Syntax error in INSERT INTO statement.” error. However when I only have 2 values to insert into 2 columns it works just fine. I’m a bit confused as to why that may be. (tip: I may not be using the correct connect string, the file type is an Access 2000 Database)
Dim Cmd As OleDbCommand
Dim SQL As String
Dim objCmd As New OleDbCommand
Dim Con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source = C:\Files\keysDB.mdb")
SQL = "INSERT INTO KeyBuffer(keypad, SID, Time) VALUES('1', '1337', '" & DateTime.Now.ToString & "')"
Cmd = New OleDbCommand(SQL, Con)
Con.Open()
objCmd = New OleDbCommand(SQL, Con)
objCmd.ExecuteNonQuery()
Con.Close()
The field name you are using for Time is likely a keyword. Try placing brackets around it: