ASP 101 - Active Server Pages 101 - Web01
The Place ASP Developers Go!

Please visit our partners

Windows Technology Windows Technology
15 Seconds
ASP 101
ASP Wire
VB Forums
VB Wire
internet.commerce internet.commerce
Partners & Affiliates

ASP 101 is an site
ASP 101 is an site
Internet News
Small Business
Personal Technology

Corporate Info
Tech Jobs
E-mail Offers

ASP 101 News Flash ASP 101 News Flash

 Top ASP 101 Stories Top ASP 101 Stories
An Overview of ASP.NET
Connections, Commands, And Procedures
What is ASP?

Make Your Scripts Filename Independent
Show All Tips >>
ASP 101 RSS Feed ASP 101 Updates

Quick Tips

Use AdExecuteNoRecords

This optional parameter can be used when you're running an ADO command in a way which normally returns records, but you know that none will actually be returned. It was introduced in ADO 2, so obviously it won't work if you're running an older version, but if you are running ADO 2.0 or greater, it's an easy way to gain some additional performance.

There is a certain level of overhead associated with ADO preparing to return a recordset. By itself this isn't that big of a deal, but there are also a number of methods in ADO which return a recordset object by default. It was realized that many of these methods were being used in a manner which resulted in recordsets being generated and returned without any records. While this behavior is fine if you happen to run a query which finds no matching results, it's pretty wasteful if you're doing an insert and aren't expecting anything back or are running a stored procedure and are only looking to get back a return value instead a recordset. It's this inefficiency from which AdExecuteNoRecords arose. It tells ADO to not spend the time to prepare a recordset for return because we know in advance that there isn't going to be one. It reduces overhaed and can thus help increase performance.

The constant is included in newer versions of the constant files as well as in the type library. It's extremely simple to use and is normally used as a parameter to the Execute method of the Connection or Command object. Here's a quick example:

cnn.Execute "INSERT INTO table (field_name) VALUES (value)", lngRecsAffected, adCmdText Or adExecuteNoRecords

The above is a line that exectes a SQL text insert command (adCmdText) which would return the number of records affected into lngRecsAffected and tells ADO that there will be no records returned. It's pretty straight forward, but you'll notice that we're not assigning the output to a recordset like you normally do with Execute commands. This is because, as the parameter says, we know there won't be one returned.

Previous      Show All Tips      Next

If you have a tip you would like to submit, please send it to:

Home |  News |  Samples |  Articles |  Lessons |  Resources |  Forum |  Links |  Search |  Feedback
The Network for Technology Professionals



Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers