Submitted By: Kent Finkle

Sample script that retrieves a Microsoft Access Recordset and then assigns that recordset to a string variable.

Visual Basic
Edit|Remove
'*  Script name:    GetString.vbs
'*  Created on:     2006-07-31
'*  Author:         Kent Finkle
'*  Purpose:        Retrieve an Access Recordset into a string.

Option Explicit

Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adClipString = 2 
Const intAllRows = -1
Const strColumnDelimiter = ","

Dim objConnection
Dim objRecordSet
dim strOut

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")

objConnection.Open "Provider= Microsoft.Jet.OLEDB.4.0; " & _
            "Data Source=C:\Scripts\Test.mdb"

objRecordSet.Open "SELECT * FROM Hardware" , objConnection, _
    adOpenStatic, adLockOptimistic

strOut = objRecordSet.GetString(adClipString, intAllRows , strColumnDelimiter)

objRecordSet.Close

objConnection.Close

MsgBox strOut