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?

  • All necessary requests to the database can be debugged with comfort in Access itself. - Bulson
  • @Bulson I need to work through the client program - axmed2004
  • You can continue to work as you like. But in advance to create the right requests, you need to test their work in Access itself. - Bulson
  • Your 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 the qry method. To forget about such errors forever, use the parameters . - Alexander Petrov
  • @AlexanderPetrov way to insert into people(col1,col2, ...) values(val1, val2, ...) works. for some reason he doesn't like the set - axmed2004

0