cmd3.ExecuteNonQuery();
中存在错误for(int i=0; i<listView1.Items.Count;i++)
{
string query2 = "INSERT INTO OrderItems(Order_ID,Item_ID,OI_Quantity,Unit_Price) values ('"+Convert.ToInt32(textBoxId.Text)+"','"+Convert.ToInt32(this.listView1.Items[i].SubItems[5].Text.ToString())+"','"+Convert.ToInt32(this.listView1.Items[i].SubItems[3].Text.ToString())+"','"+Convert.ToInt32(this.listView1.Items[i].SubItems[2].Text.ToString())+"')";
OleDbCommand cmd2= new OleDbCommand(query2,con);
cmd2.ExecuteNonQuery();
string query3 = "UPDATE Item set stock=(select stock from Item where ID='" + Convert.ToInt32(this.listView1.Items[i].SubItems[5].Text.ToString()) + "') - '" + Convert.ToInt32(this.listView1.Items[i].SubItems[3].Text.ToString()) + "' where ID='" + Convert.ToInt32(this.listView1.Items[i].SubItems[5].Text.ToString()) + "' ";
OleDbCommand cmd3 = new OleDbCommand(query3, con);
cmd3.ExecuteNonQuery();
}
答案 0 :(得分:0)
您正在使用更新查询执行减号操作,其中参数以&#39;&#39;引号,sql不作为整数。
您可以将减运算的结果存储在变量中,然后在更新查询中使用该变量。