insert problem

Jun 14 2007 5:09 AM
i have a button witch should insert into a database table 3 strings from textboxes this is the code but not working :( { string stringconexiune = @"PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=Users.mdb"; OleDbConnection conexiune = new OleDbConnection(stringconexiune); conexiune.Open(); OleDbCommand comanda = new OleDbCommand("INSERT INTO Users (Username, Password, Login) VALUES ('"+this.textBox1.Text+"', '"+this.textBox2.Text+"', '"+this.comboBox2.Text+"')", conexiune); comanda.ExecuteNonQuery();// here seems to be the problem conexiune.Close(); } when i click the buton in the project i have this exception System.Data.OleDb.OleDbException was unhandled Message="Syntax error in INSERT INTO statement." Source="Microsoft JET Database Engine" ErrorCode=-2147217900 StackTrace: at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteNonQuery() at Catalog.Catalog3.button4_Click(Object sender, EventArgs e) in D:\Programare\c#\CATALOG\Catalog\Catalog\Catalog3.cs:line 68 what shoud i do?? is there an error in my command OleDbCommand comanda = new OleDbCommand("INSERT INTO Users (Username, Password, Login) VALUES ('"+this.textBox1.Text+"', '"+this.textBox2.Text+"', '"+this.comboBox2.Text+"')", conexiune);

Answers (3)