dbTalk Databases Forums  

retrieve records affected count from ADO?

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss retrieve records affected count from ADO? in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Rich Protzel
 
Posts: n/a

Default retrieve records affected count from ADO? - 08-01-2003 , 05:53 PM






Hello,

If I run an action SP from MS Access using ADO:
...
cmd.execute

where the SP is something like Create...
Update tbl1 set fld1 = 'something' where...

how can I retrive the count of records affected like from Query
analyzer?

Thanks,
Rich

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Reply With Quote
  #2  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: retrieve records affected count from ADO? - 08-02-2003 , 03:17 AM






Rich Protzel (rpng123 (AT) aol (DOT) com) writes:
Quote:
If I run an action SP from MS Access using ADO:
..
cmd.execute

where the SP is something like Create...
Update tbl1 set fld1 = 'something' where...

how can I retrive the count of records affected like from Query
analyzer?
The first parameter to cmd.execute is RecordsAffected.

You must not have submitted SET NOCOUNT ON, to get the count.


--
Erland Sommarskog, SQL Server MVP, sommar (AT) algonet (DOT) se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp


Reply With Quote
  #3  
Old   
Rich Protzel
 
Posts: n/a

Default Re: retrieve records affected count from ADO? - 08-02-2003 , 09:53 PM



Thanks for your reply.

Quote:
The first parameter to cmd.execute is RecordsAffected.
You must not have submitted SET NOCOUNT ON, to get the count.
<<

May I ask how I go about retrieving the Count of records affected back
into MS Access?

Dim CountRecsAffected As Long
...
cmd.Parameters("@bDate").Value = sDate
cmd.Execute
CountRecsAffected = cmd.?
or
CountRecsAffected = ?
or
CountRecsAffected = cmd.Parameters.Count? Wouldn't this one just give me
the count of parameters being used?

Thanks again for your reply.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Reply With Quote
  #4  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: retrieve records affected count from ADO? - 08-03-2003 , 11:08 AM



Rich Protzel (rpng123 (AT) aol (DOT) com) writes:
Quote:
May I ask how I go about retrieving the Count of records affected back
into MS Access?

Dim CountRecsAffected As Long
..
cmd.Parameters("@bDate").Value = sDate
cmd.Execute
CountRecsAffected = cmd.?
or
CountRecsAffected = ?
or
CountRecsAffected = cmd.Parameters.Count? Wouldn't this one just give me
the count of parameters being used?
cmd.Execute CountRecsAffected

Assuming that Access works like Visual Basic.


--
Erland Sommarskog, SQL Server MVP, sommar (AT) algonet (DOT) se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp


Reply With Quote
  #5  
Old   
Trevor Best
 
Posts: n/a

Default Re: retrieve records affected count from ADO? - 08-03-2003 , 11:14 AM



On Sun, 3 Aug 2003 16:08:14 +0000 (UTC) in
comp.databases.ms-sqlserver, Erland Sommarskog <sommar (AT) algonet (DOT) se>
wrote:

Quote:
Assuming that Access works like Visual Basic.
For most things, including ADO, it does.

--
Ride Free (but you still have to pay for the petrol)

(replace sithlord with trevor for email)


Reply With Quote
  #6  
Old   
Rich Protzel
 
Posts: n/a

Default Re: retrieve records affected count from ADO? - 08-03-2003 , 11:43 PM



Thank you all for your replies. I think I get the idea now about how to
retrieve the count of records affected from an action sp.

One more question if I may:

If I set my sp to

SET NOCOUNT ON

would that improve the performance of my sp? It is not critical for me
to retrieve the count of records affected, mostly just a check. But if
the sp works consistently, and setting

SET NOCOUNT ON

significantly improve performance, then maybe I should consider that.
Most of my action sp's are affecting over 100,000 records of tables with
nearly 200 fields (no redundant fields) with over 1,000,000 records.

Thanks again,

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Reply With Quote
  #7  
Old   
Rich Protzel
 
Posts: n/a

Default Re: retrieve records affected count from ADO? - 08-05-2003 , 10:33 AM



Thanks for the link. It was very informative.

http://www.algonet.se/~sommar/error-...I.html#NOCOUNT

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.