Page 1 of 1

Determine rows affected by Update command

Posted: Fri 02 May 2008 00:43
by dghundt
I use this snippet to update row(s) in the database, but need to know the number of rows affected. What is the easiest way to get the number of rows affected? Thanks!

Code: Select all

                                    
string myInsertCommand = "UPDATE callees " +
"SET result = '" + result + "' " +
"WHERE (customer.id = " + id + ") AND (status  'BUSY')";
                                    
PgSqlCommand insertData = new PgSqlCommand(myInsertCommand, pgSqlConnection1);
pgSqlConnection1.Open();
insertData.ExecuteNonQuery();

Posted: Mon 05 May 2008 13:30
by Alexey.mdr
You can use the following line:

Code: Select all

int recordsAffected = insertData.ExecuteNonQuery();

Posted: Mon 05 May 2008 19:46
by dghundt
Thank you.

Posted: Tue 06 May 2008 11:41
by Alexey.mdr
No problem.
Feel free to contact us if you have any further questions or concerns about the product.