I have this code in textbox 2 which multiply the value of text box 1 and 2 adds the result to text box 3:
private void textBox2_TextChanged(object sender, EventArgs e)
{
textBox3.Text = Convert.ToString(Convert.ToInt32(textBox1.Text) * Convert.ToInt32(textBox2.Text));
}
When I insert the data in the database via this
code private void button1_Click(object sender, EventArgs e)
{
con.Open();
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "Insert into Receipts(Qty,ItemName,Price,Amount) values('" + textBox2.Text + "','" + textBox4.Text + "','" + textBox1.Text + "','" + textBox3.Text + "')";
cmd.ExecuteNonQuery();
con.Close();
this.receiptsTableAdapter.Fill(this.shopDataSet.Receipts);
textBox4.Clear();
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
//MessageBox.Show("Data Inserted !");
}
I get error on textBox2.Clear(); ( exceptional handling but data inserts succcessfully ) program is working fine without this,
textBox4.Clear();
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
I want to clear text boxes, i am only getting error on textbox2 which have the code to multiply the value of text box 1 and 2 adds the result to text box 3.
thanks :)