Display records where “Departure_Initials” starts with an “L”

Article Tools

This example uses the QTP_Flight32 DSN to database connection.

The example is based on the Flight Reservation demo database.

[hideit]

Dim oConn, oRst, oField
Dim sql, nCount

nCount = 1
set oConn = CreateObject( "ADODB.Connection" )

oConn.Open "QT_Flight32"
set oRst = CreateObject( "ADODB.recordset" )
sql = "SELECT Flight_Number, Airlines FROM Flights WHERE Departure_Initials LIKE 'L%'"
oRst.Open sql, oConn

For Each oField in oRst.Fields
    DataTable.LocalSheet.AddParameter oField.Name, vbNullString
Next

Do Until oRst.EOF
    For Each oField in oRst.Fields
        DataTable( oField.Name, dtLocalSheet ) = oField.Value
    Next
    oRst.MoveNext
    DataTable.LocalSheet.SetCurrentRow nCount
    nCount = nCount + 1
    If nCount > 30 Then
        Exit Do
    End If
Loop
oRst.close
oConn.close

[/hideit]

Previous postDisplay Records Next postWorking with DOS Command Line

Related Posts

Post Your Comment

You must be logged in to post a comment.