Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Microsoft: ASP (Active Server Pages) FAQ

Data Connectivity

Segment 3 - Creating a RecordSet by DreXor
Posted: 28 Jun 03 (Edited 15 Dec 04)

Recordsets, the heart behind alot of our ASP pages...

Recordsets are complex little beasts. Most people will overlook their multi-functionality due to their simplicity of use.

1.) Making a Recordset :
Using the Connection Con referenced in Segment 2 Creating a Connection....

    1a.) Easy-Peasy RecordSets :
    Commonly used for action queries where no recordset is returned, or for simple record output uses.

    Set RS = Con.Execute(StrSQL)
    where StrSQL is a valid SQL String, be it INSERT, UPDATE, SELECT, DELETE, a SP, etc.

    1b.) Creating an Active RecordSet :
    Please note that in saying 'Active' it means that the connection is open, that there is a record pointer, records are updateable, deleteable etc, not meaning that it's an active connection from server to client and bi-directional, it's only bi-directional from the web server to the data server ( if not same machine ) for the duration of the execution of code just like ASP it's server side only
    Used for handling paged recordsets (see FAQ: http://www.tek-tips.com/faqs.cfm?fid=186), modifiable pointer based recordsets, and other 'special' method based recordsets.

    Set RS = Server.CreateObject("ADODB.Recordset")
    this is where method/collection arguments and pre-populated recordset code would take place.
    RS.Open StrSQL, ActiveConnection, CursorType, LockType, Options

    Documentation on what each of the arguments are rather involved, although StrSQL is of course the SQL statement and ActiveConnection would be the Connection Object Con.
    For more information on the arguments for a recordset please see :


2.) Manipulating the RecordSet :
At this point is where record output, pointer navigations and updates/deletes would take place these are covered in Segment 4 - Using a RecordSet

3.) Closing the RecordSet Object :
Just like in the Connection Object, this is one of the most often overlooked steps, or misplaced steps in coding, it is necessary to close the Recordset otherwise the residual connection will eat up available connection slots to the data source and eat up server memory.

If step 1b was used
used for both steps 1a & 1b
Set RS = nothing

This calls RS's Close method, hence closing the active recordset ( if opened ), and Set RS=nothing clears the server memory of the recordset object

Next Section : http://www.tek-tips.com/faqs.cfm?fid=3804

Back to Microsoft: ASP (Active Server Pages) FAQ Index
Back to Microsoft: ASP (Active Server Pages) Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close