capture records Affected count from dataAdapter.Update(...?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

Is there a way to capture the Records Affected count when performing a table
Update on a Sql Server table using a DataAdapter? How is this done?

Thanks,
Rich
 
Doesn't the update method of a data adapter return the number of rows
affected?
Dim count as integer = myDataAdapter.Update(myDataTable)

You can find out BEFORE the update call by checking your
dataset/datatable and getting all rows with 'GetChanges' which returns
an array of datarows that will be updated. Naturally just get the
Length property of this returned array to get the count.

MSDN documentation covers all of this, naturally.
 
Thanks for replying to my post. I am not in the office right now, so can't
try out your suggestion. But it seems simple enough.

As for 'GetChanges', my goal is more to see a count of rows in the table on
the sql server that were affected. Like 3 rows were updated. I am guessing
that I could check 'GetChanges' on the datatable in my app before I perform
the dataAdapter.Update thing. But I am actually interested in the table in
the sql server.

Thanks again for showing me how to retrieve the count of RowsAffected for
the DataAdapter.Update method.

Rich
 
Back
Top