Contact US

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!

*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

Visual Basic (Classic) FAQ


Looping through large recordsets using ADODB.Field pointers by manitoba
Posted: 29 Jan 04

If your recordset has a lot of data - hundreds or thousands of rows, use a pointer to the column to improve performance.  It is much faster than doing this:


Here is an example:

Dim objConn As ADODB.Connection
Dim rsData As ADODB.Recordset
Dim objFieldX As ADODB.Field
Dim objFieldY As ADODB.Field
Dim strCmd As String

Set objConn = New ADODB.Connection
'Open connection
mobjDBConn.Open "....my connection string..."

'Fetch data
Set rsData = mobjConn.Execute("...my sql...")

'Get a pointer to the fields    
Set objFieldX = rsData("column_x")
Set objFieldY = rsData("column_y")

If rsData.BOF And rsData.EOF Then
    'Do something if recordset is empty
    Do Until rsData.EOF
        'Do something with the data
        'a = objFieldX.Value
        'b = objFieldY.Value

End If

'Close connection
If objConn.State <> adStateClosed Then
End If
'Clean up
Set rsData = Nothing
Set objConn = Nothing
Set objFieldX = Nothing
Set objFieldY = Nothing

Back to Visual Basic (Classic) FAQ Index
Back to Visual Basic (Classic) 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