Don't use ExecuteReader with a UPDATE Query - use ExecuteNonQuery instead. It will return an integer value, which is the number of records affected. You can check this, and decide if there were any changes.
And do not concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Use Parametrized queries instead.
"i preferred this queries because in my college they teached this kind of queries.... now what kind of queries i have to use in project for safety.... if u suggest i will start to learn.... if u dont mind can u tell.. what i have to do....? to develop secured PROJECT(application)..."
UGIcon.Open();
cmd = new SqlCommand("UPDATE purchase SET om=@OM, address=@AD, phone=@PH, baled=@BE, paid=@PD, status=@ST, balance=@BL where cm=@CM", UGIcon);
cmd.Parameters.AddWithValue("@OM", textBox2.Text);
cmd.Parameters.AddWithValue("@AD", textBox3.Text);
cmd.Parameters.AddWithValue("@PH", maskedTextBox1.Text);
cmd.Parameters.AddWithValue("@BE", numericUpDown2.Value);
cmd.Parameters.AddWithValue("@PD", textBox9.Text);
cmd.Parameters.AddWithValue("@ST", textBox4.Text);
cmd.Parameters.AddWithValue("@BL", textBox10.Text);
cmd.Parameters.AddWithValue("@CM", toolStripTextBox1.Text);
int updated = cmd.ExecuteNonQuery();
if (updated == 0)
{
MessageBox.Show("No records were updated");
}
else
{
MessageBox.Show("Details has been updated sucessfully", "Update Window", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
UGIcon.Close();
Depending on the values in your tables, you should check and convert your values to the appropriate datatypes (to prevent the user typing an alpha into a numeric field, and so on - but you should check all that at the top of your method anyway and not get this far if there is a problem.)
If your college doesn't teach you about SQL injection attacks, then you have a pretty poor lecturer. (And I would not suggest that you try to see what happens if you try one on his code - you might get expelled if you "accidentally" delete his tables...)