Syntax error on 'INSERT INTO' statement when trying to add to access database
Posted on 2004-10-30
Sorry if this should be in the DB area, but not sure if the problem is the DB or the VB code.
The following code does not work (I get a syntax error in INSERT INTO message). The database QSSupport.mdb is in the correct path with a table called 'tblKey'. That table has only one field called 'KeyCode2'. That field is a text field (50 characters), is not indexed, duplicates and zero length strings are allowed. Can anyone tell me why this is not working?:
Public Sub Update
Dim conDB2 As New OleDb.OleDbConnection
Dim cmdKey As New OleDb.OleDbCommand
Dim myDS As New DataSet
conDB2.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\QSSupport.mdb"
cmdKey.CommandText = "INSERT INTO tblKey [keycode2] VALUES '7'"
cmdKey.Connection = conDB2