Mfwamba Tshimanga

Mfwamba Tshimanga

  • NA
  • 155
  • 43.9k

A little bit strange... Its updating all the column...

Oct 10 2014 8:46 PM
Hello!

I would like to update my data. Its works well. Its do it for all the column. Before that I sorting the datas... Then I change what I want on my textbox. Suddlendly after to click its do it for all the column "name". It's very starnge!!!

Have a look:

for search:

string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\test\test\\app_data\office.mdb;Persist Security Info=False";
            OleDbConnection sqlCon = new OleDbConnection(connectionString);
            sqlCon.Open();
            string commandString = "select * from full_registardemissao where name='" + cbxFuncionarioRegistardemissao.Text + "'";
            OleDbCommand sqlCmd = new OleDbCommand(commandString, sqlCon);
            OleDbDataReader read = sqlCmd.ExecuteReader();

            if (read.HasRows)
            {
                while (read.Read())
                {
                    mskTxtDatademissao.Text = read["datademissao"].ToString(); // it will show the code
                    txtMotivoRegistardemissao.Text = read["motivo"].ToString(); // it will show the code
                    
                }
            }
            else
            {
                MessageBox.Show("A record with a code of " + mskTxtDatademissao.Text + " was not found");
            }

            read.Close();
            sqlCon.Close();

for update:


             Conn.Open();
            oleDbCmd.Connection = Conn;

oleDbCmd.CommandText = "UPDATE full_registardemissao SET name= '" + cbxFuncionarioRegistardemissao.Text + "'";
            
            oleDbCmd.ExecuteNonQuery();

            {
                {
                    MessageBox.Show("Datas saved!");
                }
                Conn.Close();
            }

Answers (1)