How to read records from an Oracle database using TestPartner

How to read records from an Oracle database using TestPartner

The following code will read column records from an Oracle database. In this example the code will read the TPFULLNAME column records in the STW_Users table of a Silk Test Workbench Oracle database.

' add reference to   Microsoft ActiveX Data Object Library
' Tools > References > Check   "Microsoft ActiveX Data Object Library"
Sub Main()
    Dim con As ADODB.connection
    Dim objRecordset As ADODB.Recordset
'Open the ADO connection
Set con = New ADODB.connection
     
'Connection string for Oracle DB
con.ConnectionString =   "DSN=_STW13_Nwb_Ora;UID=stw13;PWD=stw13"
'Open   the connection
con.Open
 
    ' Execute SQL script to retrieve data
    Set objRecordset = con.Execute("SELECT * FROM STW_Users")
     
    ' Display value in column "TPFULLNAME"
    objRecordset.MoveFirst
         
    Do While Not objRecordset.EOF
         MsgBox objRecordset.Fields.Item("TPFULLNAME").Value
         objRecordset.MoveNext
    Loop
   
    ' Close connection
    objRecordset.Close
    con.Close
 
End Sub

Incident: 2660078

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Version history
Revision #:
1 of 1
Last update:
‎2013-10-23 12:12
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.