'========================================================================== ' ' VBScript: AUTHOR: Ed WIlson, msft, 9/23/2005 ' ' NAME: ' ' COMMENT: Key concepts are listed below: '1. Uses Microsoft.Jet.Oledb.4.0 provider. Must specify DataSource as the file name. '2. Basic Tsql query. Select * from tableName '3. Print the fields by field name. '========================================================================== Option Explicit ' is used to force the scripter to declare variables 'On Error Resume Next ' is used to tell vbscript to go to the next line if it encounters an Error Dim strQuery Dim objConnection Dim objCommand Dim objRecordSet Dim strProvider 'the name of the provider Dim strDataSource Dim strFileName strProvider = "Provider=Microsoft.Jet.OLEDB.4.0" strFileName = funfix("EmployeesTest.mdb") 'Ensure script can find this file. strDataSource = "Data Source =" & strFileName strQuery = "Select * from Employees" 'Basic TSQL here ... select * from tableName Set objConnection = CreateObject("ADODB.Connection") Set objCommand = CreateObject("ADODB.Command") objConnection.Open strProvider & ";" & strDataSource objCommand.ActiveConnection = objConnection objCommand.CommandText = strQuery Set objRecordSet = objCommand.Execute Do Until objRecordSet.EOF Wscript.Echo objRecordSet.Fields("firstName"), objRecordSet.Fields("city") 'Wscript.Echo objRecordSet("firstName"), objRecordSet("city") 'Use either syntax objRecordSet.MoveNext Loop objConnection.Close ' *** function below *** Function funfix (strIN) funfix = "'" & strIN & "'" End Function