QTP code -Query a Database











Sponsored Links:


 Simple example of how to query an access database.


















dim objDB 
dim objRS 
dim intCounter

' create a database and recordset objects
Set objDB = CreateObject("ADODB.Connection")
Set objRS = CreateObject("ADODB.RecordSet")

' configure the connection
objDB.Provider="Microsoft.Jet.OLEDB.4.0"
objDB.Open 
"c:\MyTestDatabase.mdb"

' count the number of records in the employee table
objRS.Open "SELECT COUNT(*) from Employee" , objDB

Msgbox "There are " & objRS.Fields(0).Value & " records in the employee table."

' destroy the objects
Set objDB = Nothing
Set objRS = Nothing

Source: https://qtphelper.com

0 comments: