How will you connect the Database from QTP without creating a DNS

In QTP you can connect to the database by creating a DSN and then selecting the database server and the database. The other alternative to connect to the database in QTP is through a connection string. there is no need for you to create a DSN (Data Source name) but you need to know the details of the server and the userid, password and the database name.


For our reference and to understand how to create a data base connection without creating a DSN Name we will navigate to the Database Query Wizard from Insert - checkpoint - database Checkpoint.

Step 1: Open the Database Query Wizard


Step 2: Select the 'Specify SQL statement manually" radio button and click Next

Step 3: It will redirect to the next screen where you have a Create button to create a new Connection String. We will not create a new one because we need to create a DSN.Instead of that in the Connection String Text box which is below the create button enter the connection string as follows.


If you are using mysql database then use the mentioned connection string:

Driver={Mysql};server=testserver;uid=sa,password=sa;app=quicktestprofessional;database=Testdb

If you are using MS Sql database then use the mentioned connection string:

Driver={SQL Server};server=testserver;uid=sa;password=sa;app=quicktestprofessional;database=Testdb

If you are using MS Sql 2008 database then use the mentioned connection string:

Driver={SQL Server Native Client 10.0};server=testserver;uid=sa,password=sa;app=quicktestprofessional;database=Testdb


Step 4: In the SQL statement Text Box write the query you want to execute like

Select Top 10 * from employee.

Then click Finish Button.

You can see the 10 rows displayed.

If you perform the above steps for inserting a database checkpoint then you can see the result in the "database Checkpoint Properties" window displayed after clicking Finish button.


1 comments:

Anonymous said...

Hi Kiran,
Can you post how to connect with SQL Server 2012, I have trouble to connect native client 11.0.
Thanks in advance.
Gopal

Post a Comment

/* Tynt Insight tracker ----------------------------------------------- */