为什么没能正常执行,字段值没有变化,也没有显示任何错误,代码如下:
for (int kc = 0; kc < dataGridView2.RowCount; kc++)
{
//更新库存表数据
SqlCommand cmdupdatekucun = new SqlCommand("update kucun_shangpin set shuliang=shuliang - '" + Convert.ToDouble(this.dataGridView2.Rows[kc].Cells[9].Value) + "' where sp_id='" + this.dataGridView2.Rows[kc].Cells[1].Value + "'", conyewu);
cmdupdatekucun.ExecuteNonQuery(); }
for (int kc = 0; kc < dataGridView2.RowCount; kc++)
{
//更新库存表数据
SqlCommand cmdupdatekucun = new SqlCommand("update kucun_shangpin set shuliang=shuliang - '" + Convert.ToDouble(this.dataGridView2.Rows[kc].Cells[9].Value) + "' where sp_id='" + this.dataGridView2.Rows[kc].Cells[1].Value + "'", conyewu);
cmdupdatekucun.ExecuteNonQuery(); }
解决方案 »
- 如果禁用tab键
- 在pictureBox1 上添加文字
- VS 2008自带报表模版添加数据源报错
- 请问,这个C#.net,和原来的c#,还有C# builder之间是个什么关系?
- VS2005下System.Windows.Forms.WebBrowser的问题
- 请各位帮忙,,数据显示不了,上下页错误,程序调试没错,就是没显示
- VS中C# 将汉字转为unicode存入数据库有什么办法
- 请问,.net2005中,如何加入namespace?
- checkbox的values的值怎么获得??
- WinForm窗体包含DataGridView继承后不能修改吗
- DataGridView的cellclick事件问题
- 运算符“==”无法应用于type 和type! 晕了 这是怎么回事呀? 在线等
然后拷到sql分析器去执行下
SqlCommand cmdupdatekucun = new SqlCommand("update kucun_shangpin set shuliang='" + (shuliang - Convert.ToDouble(this.dataGridView2.Rows[kc].Cells[9].Value)) + "' where sp_id='" + this.dataGridView2.Rows[kc].Cells[1].Value + "'", conyewu);
如果shuliang是int就不加单引号
sp_id也是
提示“当前上下文中不存在名称shuliang”