QTP10.com is a new and completely free website that offers help in all the versions of HP QTP (including latest version 10). More importantly, it offers free code for users of HP QuickTest Professioal. This site helps you in learning the basics of QTP and descriptive/advanced programming in (QTP) on various environments like - .Net, Infragistics, Web, Windows, etc.

Note -
This blog is NOT affiliated with HP / Hewlett-Packard in any way. The data/questions come from various sources and we have our own testing questions. I am just another Software Tester like you.

how to query an access database by QTP

Share This Post -

Sponsored Links:

Simple QTP Script/code example of how to query an access database.

 

This is my tutorial on how to build a query that you can use in VBScript to extract information from a database.
The level of difficulty for this tutorial is beginner to intermediate.


You need to know basic VBScript syntax and need to have a copy of MS Access.

 


Code Starts from here:

 

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