Demonstrate Ability to Read Database:

This snippet requires you to have "QT_Flight32" set up as a system DSN and have the QT examples installed. If not, create an Access DB and a DSN and change the name in the script. This script should loop about 10 times and give you departure cities in the QT_Flight32 db. Just save the code fragment as "Example.vbs" on your disk where you can easily get to it. Double-click on the file name to execute it. You don't need QT running. You can also copy this as-is into a QTP Script and execute it. You can adapt and modify as necessary as well as wrap it in a function.

Const FLT_con = "DSN=QT_Flight32"

Dim FLT_db_con
Dim rs, Get_DepartCities, RecOut

Set FLT_db_con = CreateObject("ADODB.Connection")

Get_DepartCities = "SELECT DISTINCT Departure FROM Flights"
Set rs = FLT_db_con.Execute(Get_DepartCities)
rs.MoveFirst '-- First record in db is null
rs.MoveNext '---- Get past it.

Do while rs.EOF = FALSE

RecOut = rs("Departure")
MsgBox "Departure City: " + (RecOut)

Set rs = Nothing
Set FLT_db_con = Nothing