i write following code to update database but every time i got update syntax error is anyone help me to ..

MessageBox.Show("the password is matched");
                String conString = "Provider=Microsoft.Jet.OLEDB.4.0;"
                 + "Data Source=C:\\Documents and Settings\\Wasif\\My Documents\\studentLogin.mdb";
                OleDbConnection empConnection = new OleDbConnection(conString);
                String insertStatment = "UPDATE StudentLoginData Set ID='" + this.txt_id.Text + "', username='" + this.txt_username.Text + "', password='" + this.txt_password.Text + "'  WHERE ID="+this.txt_id.Text+";";
                
                OleDbCommand insertCommand = new OleDbCommand(insertStatment, empConnection);

                //insertCommand.Parameters.Add("ID", OleDbType.Char).Value = strID;
                //insertCommand.Parameters.Add("username", OleDbType.Char).Value = strusername;
                //insertCommand.Parameters.Add("password", OleDbType.Char).Value = strpassword;
                empConnection.Open();
                try
                {
                    int count = insertCommand.ExecuteNonQuery();

                }
                catch (OleDbException o)
                {
                    MessageBox.Show(o.Message);
                }
                finally
                {

                    empConnection.Close();
                }

Always use parametrized query.

String conString = "Provider=Microsoft.Jet.OLEDB.4.0;"
                 + "Data Source=C:\\Documents and Settings\\Wasif\\My Documents\\studentLogin.mdb";

OleDbConnection empConnection = new OleDbConnection(conString);

String insertStatment = "UPDATE StudentLoginData Set [username]='" + this.txt_username.Text + "',[password]='" + this.txt_password.Text + "'  WHERE [ID]="+this.txt_id.Text+"";
                
                OleDbCommand insertCommand = new OleDbCommand(insertStatment, empConnection);

              empConnection.Open();
                try
                {
                    int count = insertCommand.ExecuteNonQuery();

                }
                catch (OleDbException o)
                {
                    MessageBox.Show(o.Message);
                }
                finally
                {

                    empConnection.Close();
                }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.