sqlCmd = new SqlCommand();
sqlCmd.Connection = sqlCon;
sqlCmd.CommandText = "update trainn set Adultno=Adultno-1 where ID=@pram1 and
adult=@pram2 and Adultno>0";
sqlCmd.Parameters.AddWithValue("@pram1", textBox3.Text);
sqlCmd.ExecuteNonQuery();
sqlCon.Close();
The code is working properly when there is an update,but when it comes to more than
one I don't know what to do? The following code is the one which I thought it may
work, but actually it doesn't make sense! any suggestion?
sqlCmd = new SqlCommand();
sqlCmd1 = new SqlCommand();
sqlCmd.Connection = sqlCon;
sqlCmd1.Connection = sqlCon;
sqlCmd.CommandText = "update trainn set Adultno=Adultno-1 where ID=@pram1 and
adult=@pram2 and Adultno>0";
sqlCmd1.CommandText = "update trainn set childno=childno-1 where ID=@pram1 and
child=@pram2 and childno>0";
sqlCmd.Parameters.AddWithValue("@pram1", textBox3.Text);
sqlCmd.ExecuteNonQuery();
sqlCmd1.ExecuteNonQuery();
sqlCon.Close();