oledbcommand executenonquery访问更新错误

时间:2014-11-13 05:46:36

标签: c# ms-access oledbconnection oledbcommand

当我运行此代码时显示错误,请帮助我!

`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 个答案:

答案 0 :(得分:1)

也许你应该添加"'"对于文本列

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

如果不是,那么消息错误是什么