Export (0) Print
Expand All

Using the Recordset Object

SQL Server 2000

The Recordset object provides methods for manipulating result sets. It allows you to add, update, delete, and scroll through rows in the recordset.

A Recordset object can be created using the Execute method of the Connection or Command object.

Each row in a recordset can also be retrieved and updated using the Fields collection and the Field object. Updates on the Recordset object can be in an immediate or batch mode. When a Recordset object is created, a cursor is opened automatically.

The Recordset object allows you to specify the cursor type and location for fetching the result set. With the CursorType property, you can specify whether the cursor is read-only, forward-only, static, keyset-driven, or dynamic. Cursor type determines if a Recordset object can be scrolled or updated and affects the visibility of changed rows. By default, the cursor type is read-only and forward-only.

An application can specify the location of the cursor with the CursorLocation property. This property allows you to specify whether to use a client or server cursor. The CursorLocation property setting is important when you use disconnected recordsets.

The first part of the cmdExecute_Click method in the ADO Introductory Visual Basic Sample shows an example of creating, opening, passing a command string variable to, and positioning the cursor in a recordset.

Dim cn As New ADODB.Connection
Dim rs As ADODB.Recordset
. . . 
cmd1 = txtQuery.Text
Set rs = New ADODB.Recordset
rs.Open cmd1, cn
rs.MoveFirst
. . .
' Code to loop through result set(s)

See Also

Using Cursors with ADO

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft