oledbcommand executenonquery access update error

391 views Asked by At

when i run this code it shows error, please help me!

`int code = int.Parse(tbxcode.Text);
string name = tbxname.Text;
string description = tbxdescription.Text;
bool active = true;
int idcompany = cbxcompany.SelectedIndex;
string kala = cbxkala.SelectedValue.ToString();
int id = int.Parse(kala);
oleDbCommand1.Parameters.Clear();
oleDbCommand1.CommandText = "update kala set code=" + code + ", name=" + name + ", description=" + description + ", active=" + active + ", idcompany=" + idcompany + " where id=" + id;
oleDbConnection1.Open();
oleDbCommand1.ExecuteNonQuery();
oleDbConnection1.Close();
oleDbCommand1.Parameters.Clear();`
1

There are 1 answers

0
MediSoft On BEST ANSWER

Maybe you should add the "'" for text column

oleDbCommand1.CommandText = "update kala set code=" + code + ", name='" + name + "',   description='" + description + "', active=" + active + ", idcompany=" + idcompany + " where id=" + id;

if it's not that, what's the message error