Hello everyone,
I have to change the data in one of the fields in my table in access.
I use the update query.
but the query only deleting the old data from the table and not entering the new data with the foll code.
code:
String esql = string.Format("update company_list SET company_name ='{0}' where company_name ='{1}'", edited_name, selected_name);
OleDbCommand myupdate = new OleDbCommand(esql, con);
myupdate = new OleDbCommand(esql, con);
myupdate.ExecuteNonQuery();
so, I try to change the code, but here, it says that @new_name must have a default value.
but how to set a default value
code:
using (OleDbCommand myupdate = con.CreateCommand())
{
myupdate.CommandText = "update company_list set company_name = @new_name where company_name = @old_name";
myupdate.Parameters.AddWithValue("@new_name",edited_name);
myupdate.Parameters.AddWithValue("@old_name", selected_name);
myupdate.ExecuteNonQuery();
}
Please help asap.