QTP – Accessing SQL Server for automation test needs

Here’s the script that will enable you to connect to SQL Server Database and carry out basic functional tests.

Enhance the script as you may deem fit to cater to your testing needs. All the best.

Dim objCon,objRS
Set objCon = CreateObject(“ADODB.Connection”)
Set objRS = CreateObject(“ADODB.Recordset”)
objCon.Open “Provider=sqloledb.1; server=Server_CORD;uid=abhilash;pwd=password;database=OrgDB”

‘You can also specify the IP address for the server.
objRS.Open “select * from employee”, objCon
Do while not objRS.EOF
Msgbox rs.fields.item(1)
‘ You can add any code that would enable you to carry out unit testing, functional testing and so on.

I hope it has provided you the base to help develop your own advanced level database accessing scripts.

Published by Abhilash Gopi

Am a simple guy, loves to see the smiles on my friend's faces. So what are you waiting for? Be my friend, Guys n Gals.

4 thoughts on “QTP – Accessing SQL Server for automation test needs

  1. First of all. Thanks very much for your useful post.

    I just came across your blog and wanted to drop you a note telling you how impressed I was with the information you have posted here.

    Please let me introduce you some info related to this post and I hope that it is useful for software testing community.

    There is a good Software Testing resource site, Have alook




Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: