Display records where “Departure_Initials” starts with an “L”
Posted by admin - Apr 12, 2008 ADODB, Articles, Dani Vainstein, QTips 0 1 Views : 316 Receive Updates For This Category
Article Tools
- Print this page
- Add Comment
- Send to Friend
- Last Updated on :
Jul 16, 2011
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]


