Tag Archive: ADO

Apr 12 2008

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

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%'” …

Continue reading »

Apr 12 2008

Display Records

The following example demonstrates how to display all records from a table. and loop thorough a record-set. Dim oConn, oRst, oField Dim sql set oConn = CreateObject(“ADODB.Connection”) oConn.Open “QT_Flight32” set oRst = CreateObject(“ADODB.recordset”) oRst.Open “Select * from Orders”, oConn Do Until oRst.EOF For each oField in oRst.Fields Print oField.Name & ” = ” & oField.Value …

Continue reading »

Apr 01 2008

Sort data with disconnected record set

Sorts numerical data using a disconnected record set. [hideit] Const adInteger = 3 Const MaxCharacters = 10 Dim sampleArr( 20 ) For i = LBound( sampleArr ) to UBound( sampleArr ) sampleArr( i ) = RandomNumber( 1, 1000 ) Next Print “Array before sorting :” For Each num In sampleArr Print num Next ‘ ** …

Continue reading »

Apr 01 2008

Add a New Record to a Table

The following code demonstrates how to add a new record to a table. The example uses the Flight Reservation Database. Const adOpenStatic = 3 Const adLockOptimistic = 3 Set oConn = CreateObject( “ADODB.Connection” ) Set oRst = CreateObject( “ADODB.Recordset” ) oConn.Open “QT_Flight32” oRst.Open “SELECT * FROM Flights” , oConn, adOpenStatic, adLockOptimistic oRst.AddNew oRst( “Flight_Number” ).Value …

Continue reading »