NCS Logo - Click for home page Northstar Developer Center
Platforms
All Platforms
.NET Framework (1.x - 4.x)
Active Server Pages
ASP.NET
C#
SQL Server
VB.NET
Visual Basic

Keywords
.NET Data Types
.NET E-mail
.NET Events
.NET Functions
.NET Object Programming
.NET System.Configuration
.NET System.Diagnostics
.NET System.IO
.NET System.Net
.NET System.Net.Sockets
Active Data Objects
ASP Architecture
ASP Black Belt
ASP Built-in Functions
ASP Built-in Objects
ASP Debugging
ASP Performance
ASP Security
ASP Syntax
ASP.NET Authentication
ASP.NET Controls
ASP.NET Data Access
ASP.NET Features
ASP.NET Master Pages
ASP.NET Page Events
ASP.NET Security
ASP.NET ViewState
Atom
Certifications
COM, DCOM, COM+
Data Access
E-Mail
Errors
Exporting Data
HTML Tips
IIS
Object-Oriented Programming
RSS
SQL
Uncategorized ASP Tips
VB API Programming
VB Forms
VB Syntax
XML

Book Support
Visual Basic 6 Bible
ASP Bible
ASP Weekend Crash Course
ASP.NET At Work
Creating Web Services

Creating Forward-Only Recordsets

Written by Eric Smith, Northstar Computer Systems LLC

In previous tips, you've learned that when you use the ADO Connection object's Execute method to create a recordset, that recordset is a read-only, forward-only recordset. Here's an example:
Dim cnDB    ' As ADODB.Connection
Dim rsData   ' As ADODB.Recordset
Set cnDB = Server.CreateObject("ADODB.Connection")
cnDB.ConnectionString = "Provider=SQLOLEDB;" _
   & "Data Source=(local);" _
   & "Initial Catalog=Northwind;" _
   & "User ID=sa;" _
   & "Password=;"
cnDB.Open
Set rsData = cnDB.Execute("SELECT * FROM Customers")
The forward-only recordset is the most efficient type of recordset when you simply need to read data from the database. It doesn't include all the overhead of a static recordset, but it doesn't allow you to manipulate the records with methods other than MoveNext.

If you are using other types of recordsets and want to be consistent with how you open your recordsets, you can open a forward-only recordset using the Open method, as shown here:

Set rsData = Server.CreateObject("ADODB.Recordset")
rsData.Open "SELECT * FROM Customers", cnDB, adOpenForwardOnly
This constant is available as long as you've either included adovbs.inc in your file or you've referenced the ADO library using a METADATA tag, as I've shown in previous tips.

Keywords: [ Active Data Objects ]

Publication Date: 11/1/2000