Professional Documents
Culture Documents
}
Chapter 11 – Slide 3
Buying
1- update the quantity when a buy is done for example
sql =“ UPDATE book SET quantity = quantity - 1 where (title ='" +
TextBox1.Text + "' )";
2- search and get and print the price
string sql, sql2;
sql = "UPDATE book SET quantity = quantity - 1 where (title ='" + TextBox1.Text + "' )";
SqlConnection conn = new SqlConnection("Data Source=localhost\\SqlExpress;Initial
Catalog=dad;Integrated Security=True");
if (reader.Read())
{ Label1.Text = " you must pay<br />" + (int)reader["price"]; }
else
{ Label1.Text = "no user found "; }
reader.Close();
conn.Close();