How to Create a ODBC DSN connection to InterSystem’s Cache DB using QuickTest Professional


Here are the steps to install an ODBC driver for InterSystem’s Cache database and code to connect and execute a query in QTP.

1. Install the ODBCDriver.exe Client ODBC Driver Install Instersystems
2. Go to your Control Panel\Administrative Tools\Data Sources (ODBC)
3. Go to User DSN and click on Add:












5. Fill in the following info:






6. Open QTP and enter the following code:

Dim dbexample
Dim sqlQuery
' Create the conection object.
Set dbexample = CreateObject("ADODB.Connection")
'Your query info will be different 
sqlQuery = "Select Reg.Pat.PatientNm, Reg.Pat.Mrn From Reg.Pat"
' Get the recordset returned from a select query.
Set recordset = dbexample.Execute(sqlQuery)
' Display the results of the query.
print recordset.GetString
' Close the database connection.
Set dbexample = Nothing

QTP Database Testing – DSN Connection String Examples for MySQL, SQL Server and Excel — Joe Colantonio -- Test Automation Geek | Bibliomaniac | Software Imagineer - August 11, 2011

[…] The downside to this approach is that for every machine on which you plan to run your QTP test on you will also need to setup a DSN on that machine with the same info that you created earlier. For an example of setting up an ODBC DSN, check out my post entitled “How to create a ODBC DSN Connection.” […]

Jim - April 25, 2012

I don’t see the code specified after Step #6?

    Joe Colantonio - April 25, 2012

    Jim » Sorry about that Jim – it should show up now.

Click here to add a comment

Leave a comment: