OleDbException in my update method
- by Hamed Norouzi
Why do I have this error? The error message is: Syntax error in INSERT INTO statement.
I want to add a record to my database, but it isn't working. Where is the problem?
The code is:
using (OleDbConnection connection = new OleDbConnection(connectionString))
{
OleDbDataAdapter DbDataAdabter = new OleDbDataAdapter();
DbDataAdabter.SelectCommand = new OleDbCommand("SELECT * FROM [Phone-Book]", connection);
OleDbCommandBuilder cb = new OleDbCommandBuilder(DbDataAdabter);
connection.Open();
DataRow dataRow = myDataset.Tables["salam"].NewRow();
dataRow[1] = textBox2.Text;
dataRow[2] = textBox3.Text;
dataRow[3] = textBox4.Text;
dataRow[4] = textBox5.Text;
dataRow.EndEdit();
myDataset.Tables["salam"].Rows.Add(dataRow);
DbDataAdabter.Update(myDataset , "salam");
connection.Close();
connection.Dispose();
}
}