-1
我想更新我的庫存數量,保持以前的庫存狀態。我需要根據內部或外部交易增加或減少以前的數據。我沒有獲得當前庫存更新的股票。 //這是問題段的開始我想更新我的庫存數量,保持以前的數量。
SqlCommand cmd2 = new SqlCommand("select stock from currentstock where [email protected]", con);
con.Open();
int x=0;
cmd2.Parameters.AddWithValue("@a",comboBox2.SelectedItem.ToString());
SqlDataReader dr = cmd2.ExecuteReader();
if (dr.Read())
{
x = dr.GetInt16(2);
}
if (radioButton1.Checked == true)
{
x = x + Convert.ToInt16(textBox1.Text);
}
else if (radioButton2.Checked == true)
{
x = x - Convert.ToInt16(textBox2.Text);
}
con.Close();
SqlCommand cmd1 = new SqlCommand("update currentstock set [email protected] where [email protected]",con);
con.Open();
cmd1.Parameters.AddWithValue("@a", x);
cmd1.Parameters.AddWithValue("@b", comboBox2.SelectedItem.ToString());
cmd1.ExecuteNonQuery();
con.Close();
//這是問題段結束
那麼問題出現在哪裏? –
x = x + Convert.ToInt16(textBox1.Text); x = x - Convert.ToInt16(textBox2.Text); 我認爲這兩個陳述沒有得到執行。 – user3275519
請解釋你在哪條線上面臨的問題以及出現什麼樣的錯誤或異常, –