OleDbException in my update method

Posted by Hamed Norouzi on Stack Overflow See other posts from Stack Overflow or by Hamed Norouzi
Published on 2012-11-29T21:45:25Z Indexed on 2012/11/29 23:04 UTC
Read the original article Hit count: 350

Filed under:
|

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();
    }
}

© Stack Overflow or respective owner

Related posts about c#

Related posts about oledb