This is my personal blog for my software testing study purposes. The topics posted in this blog are mine and from some other sources (credits are given). I always add those topics which helps me. Hope these topics will help you guys also.
- Happy testing

Recent Posts

QTP & Keyword Driven Testing

Tricky Questions in QTP

Asset Upgrade tool in QTP

New Features in QTP 10

Sep 13, 2008

Connecting to DB through QTP

Subscribe the QA and Software Testing Newsletter
Post Your Queries | QA and Testing - Table of Contents

SPONSORED LINKS Reading: Connecting to DB through QTPTweet this Post

Methods Used: ADO Connection object

What is ADO connection?

Microsoft’s ActiveX Data Objects (ADO) is a set of Component Object Model (COM) objects for accessing data sources. It provides a layer between programming languages and OLE DB (a means of accessing data stores, whether they be databases or otherwise, in a uniform manner). ADO allows a developer to write programs that access data without knowing how the database is implemented. You must be aware of your database for connection only. No knowledge of SQL is required to access a database when using ADO, although one can use ADO to execute arbitrary SQL commands. The disadvantage of this (i.e. using SQL directly) is that it introduces a dependency upon the type of database used.

To learn more about ADO visit http://www.w3schools.com/ADO/ado_ref_connection.asp

Let us look how to connect to database(DB) in QTP, the steps involved are


  1. Create an object of type ADODB.Connection.

  2. Using the connection string establish a connection to the DB.

  3. Execute the query and store the query result to Recordset collection.

Let us see code snippet how to connect to the flights MS Access DB

STEP 1:

Set connect = CreateObject (”ADODB.Connection”)

STEP 2:

This can be done by many ways, if there is a system DSN created then you can use that directly to establish a connection.

connect.open “QT_Flight32″ ‘here this is the QT_Flight32 is the system DSN name.

if there is no system DSN, then you can give the DB details directly as

Connect.open “Driver={Microsoft ODBC for Oracle}:Server=DBserver,UID=Sa,Password=sa”

Here you have to give the Driver type like oracle,sybase then server name, user id and password.

STEP 3 :

Set RS = connect.execute(”select flight_number from flights where flight_number = 2004″ )

Now the RS object has the query result ,using loop we can get those data.

Do

For i = 0 To count1-1

MsgBox(RS.fields(i).name)

MsgBox(RS.fields(i).value)

Next

RS.MoveNext

Loop until RS.EOF

SPONSORED LINKS

Comments :

0 comments to “Connecting to DB through QTP”

Software testing Metrices-Test Case Review

Metrics are the means by which the software quality can be measured; they give you confidence in the product.

 

Energize your test team

You're waist deep in your third month of late nights, weekends, and shipping stress; you can see and feel your team's energy waning.

 

The Value of Positive Testing

There is a school of thought in software testing that debunks the value of positive testing. This school basically states that any test that does not produce a defect is not a good test.

Impact Analysis Checklist for Req. Changes
___    Implications of the Proposed Change* Identify any existing requirements in the baseline that

The Process of Test Process Improvement

Software testing is still a pain-in-the-neck for many organizations. Because it is only marginally addressed in software process improvement models like CMMi

 

Software Defect-bug Management Philosphy

Imperfect processes cause most of the software defects. Thus to prevent defects, the development process needs to be overhauled.

 

Software testing Metrices-Test Case Review

Metrics are the means by which the software quality can be measured; they give you confidence in the product.

 

Energize your test team

You're waist deep in your third month of late nights, weekends, and shipping stress; you can see and feel your team's energy waning.

 

The Value of Positive Testing

There is a school of thought in software testing that debunks the value of positive testing. This school basically states that any test that does not produce a defect is not a good test.

Blog Archive