I'm having this strange new problem writing to an Access database. I made a simple test program which executes a simple SQL query, but I'm getting back the exception: "Syntax error in INSERT INTO statement." And I can't figure out why. Here's the code...
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;" +
@"Data source=" + "D:\\DataArchive\\test.mdb";
OleDbCommand dbSelectCommand = new OleDbCommand();
dbSelectCommand.Connection = conn;
sql = "INSERT INTO Events (Data) VALUES (22)";
dbSelectCommand.CommandText = sql;
OleDbDataReader reader = dbSelectCommand.ExecuteReader(); // xxxx
catch (Exception ex)
I made a new Access database ("Test.mdb") and table ("Events") containing a singgle column ("Data") of type "Number".
The previous code compiles and executes, but once it hits ExecuteReader() it throws the exception: "Syntax error in INSERT INTO statement." Clearly there's something else going on besies the SQL statement, since the SQL is well formed. Does anyone have any ideas of what I can try? I'd be really appreciative since it's got me stopped cold.