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();
}
Anoop Kumar SharmaPosted Oct 10, 2014, 10:38 PM
Conn.Open();
oleDbCmd.Connection = Conn;
oleDbCmd.CommandText = "UPDATE full_registardemissao SET name= '" + cbxFuncionarioRegistardemissao.Text + "'";
oleDbCmd.ExecuteNonQuery();
{
{
MessageBox.Show("Datas saved!");
}
Conn.Close();
}
Here you are updating your record without using where clause. If you don't you the where clause all the records on the table will be affected.
Hope This will Help you.