Determine rows affected by Update command

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
dghundt
Posts: 38
Joined: Thu 24 Aug 2006 01:16

Determine rows affected by Update command

Post by dghundt » Fri 02 May 2008 00:43

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();

Alexey.mdr
Posts: 729
Joined: Thu 13 Dec 2007 10:24

Post by Alexey.mdr » Mon 05 May 2008 13:30

You can use the following line:

Code: Select all

int recordsAffected = insertData.ExecuteNonQuery();

dghundt
Posts: 38
Joined: Thu 24 Aug 2006 01:16

Post by dghundt » Mon 05 May 2008 19:46

Thank you.

Alexey.mdr
Posts: 729
Joined: Thu 13 Dec 2007 10:24

Post by Alexey.mdr » Tue 06 May 2008 11:41

No problem.
Feel free to contact us if you have any further questions or concerns about the product.

Post Reply