c#写图书管理系统的时候别的地方都没有问题,在销售数据录入的时候一直报书号附近有错误的情况,但是找了半天没用找到,求大家解答!
try
{
SqlConnection con = DBConnet.con();
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "UPDATE sell SET 数量 = '" + TxtOnum.Text + "',支付方式 ='"
+ TxtPay.Text + "' WHERE 客户号= '" + comboCnum.Text + "' and 书号= '"
+ comboBnum.Text + "' and 销售时间 ='" + TxtTime.Text + "'";
cmd.Connection = con;
cmd.ExecuteNonQuery();
MessageBox.Show("修改数据成功!");
string sql = "select * from sell";
SqlDataAdapter adapter = new SqlDataAdapter(sql, con);
DataSet ds = new DataSet();
adapter.Fill(ds, "sell");
dataGridView1.DataSource = ds.Tables[0].DefaultView;
con.Close();
}
catch (Exception ex)
{ MessageBox.Show(ex.Message); }
cmd.CommandText = "UPDATE sell SET 数量 = '" + TxtOnum.Text + "',支付方式 ='"
+ TxtPay.Text + "' WHERE 客户号= '" + comboCnum.Text + "' and 书号= '"
+ comboBnum.Text + "' and 销售时间 ='" + TxtTime.Text + "'";
主要是这里附近 说我书号附近有错误,但是名字什么都是对的不知道哪里错了
查看一下cmd.CommandText ,
或者使用参数化,
可能你是变量有关键字、引号
错误信息中左下角:详细信息,点开一下啥