title: How to deduct quantity from stock C# sql
body: <p>Once the product is bought it should reduce from stock quantity</p>
  
  <pre><code>double qun;
  
  qun = Convert.ToDouble(dataGridView1.Rows[0].Cells[3].Value) - Convert.ToDouble(textBox2.Text);
  
  sqlconnection = new SqlCeConnection(ConnectionString);
  sqlcommand = new SqlCeCommand();
  sqlconnection.Open();
  sqlcommand.Connection = sqlconnection;
  sqlcommand.CommandText = (@"UPDATE ItemStock_Info SET Quantity =@qun WHERE [Item_Number]='"+ textBox1.Text +"'");
  sqlcommand.Parameters.Add("@qun", qun);
  
  sqlcommand.ExecuteNonQuery();
  sqlconnection.Close();
  </code></pre>