Wednesday, 19 October 2011

QTP Script: 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


1 comments:

  1. Hi there! Do you use Twitter? I'd like to follow you if that would be ok.
    I'm absolutely enjoying your blog and look forward to new
    updates.

    Feel free to surf to my weblog planet minecraft

    ReplyDelete