Get affected rows on ExecuteNonQuery
ExecuteNonQuery
- returns the number of rows affected.
SqlCommand comm;
// other codes
int numberOfRecords = comm.ExecuteNonQuery();
If you run the SQL from your question in a SqlCommand
and check the return value of ExecuteNonQuery
it should tell you how many records were affected.
From the documentation:
Return Value
Type: System.Int32
The number of rows affected.
Be sure of one thing also You need to add a statement in the connection string For example:
string const "Server=localhost; PORT=3306; Database=db; User id=root; password='';UseAffectedRows=True";
MySqlConnection con = new MySqlConnection(const);
con.Open();
MySqlCommand cmd = new MySqlCommand(con);
cmd.CommandText = "Update db set table = value where Column = value";
int numberOfRecords = cmd.ExecuteNonQuery();
Be sure of:
UseAffectedRows=True
so it will return a right value of rows affected