이전 재고 보유 상태를 유지하면서 재고 수량을 갱신하고 싶습니다. 내부 또는 외부 트랜잭션에 따라 이전 데이터를 추가하거나 줄여 업데이트해야합니다. currentstock 테이블에서 주식을 업데이트하지 않습니다. 이이 문제 세그먼트 (segment)의이전 수량을 유지하면서 재고 수량을 갱신하고 싶습니다.
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
어떤 라인에서 어떤 문제가 발생했는지, 어떤 오류나 예외가 발생하면 설명하십시오. –