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

Please visit our partners


Windows Technology Windows Technology
15 Seconds
4GuysFromRolla.com
ASP 101
ASP Wire
VB Forums
VB Wire
WinDrivers.com
internet.commerce internet.commerce
Partners & Affiliates














ASP 101 is an
internet.com site
ASP 101 is an internet.com site
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
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?

QUICK TIP:
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: webmaster@asp101.com.


Home |  News |  Samples |  Articles |  Lessons |  Resources |  Forum |  Links |  Search |  Feedback

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

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