in the accdb database there is such a table
name1 name2 name3 birthdate .... all fields in the properties "Required field - no, Empty lines - yes"
connect to base
static string connStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source = D:/123/db.accdb"; OleDbConnection conn = new OleDbConnection(connStr); private void qry(string q) { conn.Open(); OleDbCommand cmnd = new OleDbCommand(q, conn); cmnd.CommandType = CommandType.Text; cmnd.ExecuteNonQuery(); conn.Close(); } trying to add a string
try{ qry("insert into people set name1='" + name1_ + "', name2='" + name2_ + "', name3='" + name3_+"'"); } catch (Exception exc) { MessageBox.Show(exc.Message); } I get "Syntax error in INSERT INTO statement" where is the error? and how to get a more detailed description of the sql error?
name*_variables probably contain the characters to be escaped. Check what sql query you have turned out by displaying it on the console or in the log at the beginning of theqrymethod. To forget about such errors forever, use the parameters . - Alexander Petrovinsert into people(col1,col2, ...) values(val1, val2, ...)works. for some reason he doesn't like the set - axmed2004