0% found this document useful (0 votes)
53 views4 pages

Data Base Connections: 1. How To Connect

This document discusses connecting QTP tests to databases to retrieve and use test data. It provides details on: 1. Connecting to a database by specifying the driver/provider (e.g. Microsoft Jet) and location (e.g. a Microsoft Access database file). 2. Establishing a connection object and recordset object in QTP to interface with the database. 3. Retrieving data from the database table using the recordset and using that data in test scripts (e.g. populating edit fields). The process is demonstrated for a Microsoft Access database, and Oracle and SQL connections are also briefly addressed. Feedback is requested to be sent to the provided email.

Uploaded by

Ramu Palanki
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views4 pages

Data Base Connections: 1. How To Connect

This document discusses connecting QTP tests to databases to retrieve and use test data. It provides details on: 1. Connecting to a database by specifying the driver/provider (e.g. Microsoft Jet) and location (e.g. a Microsoft Access database file). 2. Establishing a connection object and recordset object in QTP to interface with the database. 3. Retrieving data from the database table using the recordset and using that data in test scripts (e.g. populating edit fields). The process is demonstrated for a Microsoft Access database, and Oracle and SQL connections are also briefly addressed. Feedback is requested to be sent to the provided email.

Uploaded by

Ramu Palanki
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 4

For QTP Realtime Scripts, visit www.ramupalanki.

com
Data Base Connections

Test data may be in Database, so that we should connect our test to database and
retrieve the data and use the same in test.

We should know 3 things while we dealing with database connections viz..

1. How to Connect 2. How to Establish connection 3. How to Retrieve and use the data

 For connection , we need to provide two things

1. Driver / Provider : A third party software used for establishing the connection between front end

and back end of the application.

2. Location : Location of database


Record
Set : It is a temporarily location where we can store the retrieve data from data base at time.
From that temporarily location we can use the data one by one or as per requirem ent in our
Connection
: testing.
Connects the application and database.

* We need to create Object Instances for both Record Set and Connection.
Example : For example, test data is stored as below, do write the database
connection script. Testdata.mdb

re
v1 v2 s
10 20 30
30 30 60
30 20 50
90 90 180
2 8 10
For QTP Realtime Scripts, visit www.ramupalanki.com
MSACCESS
For :

‘ Dimensioning connection (con) and recordset (rs)


Dim con, rs
‘Creating object instanced for both above con and rs
‘ adodb = ActiveX Data Object Database
Set con = CreateObject (“adodb.connection”)
These two lines never
Establishing Set rs = CreateObject(“adodb.recordset”) changed

the Connection ‘ Assigning the connection with 3rd party provider i.e with microsoft

con.provider = “Microsoft.jet.oledb.4.0” *
‘ Opening the database by specifying the
location
con.open “d:/automation/testdat.mdb”
‘Retrieving the data from data table

Retrieving the data rs.open “select * from info”,con

‘ by using the retrieved data , checking all the rows


‘eof : eng of file
‘ not = if the record is not end of file then go into the loop
‘ else come out from the loop
Do while not rs.eof
‘ inserting the retrived data (v1) into val1 edit field
Vbwindow(“form1”).vbEdit(“val1”).set rs.field(“v1”)
Using the Data ‘ inserting the retrived data (v2) into val2 edit field
Vbwindow(“form1”).vbEdit(“val2”).set rs.field(“v2”)
‘ clicking on ADD button Vbwindow(“form1”).vbButton(“ADD”).click ‘ changing the focus to next
row rs.moveNext
‘ continuing the loop till eof

Loop

=============================

* For Oracle and SQL we will write both Provider name and Connection in one line and rest is same.

For Oracle

con.open “provider=oraoledb.1;server=locahost;uid=userID;pwd=password;database=database name”

For SQL

con.open “provider=sqloledb.1;server=locahost;uid=userID;pwd=password;database=database name”

-: The End :-

Pls. leave your feed back (both +ve and –ve ) at [email protected]

You might also like