EzineArticles - Expert Authors Sharing Their Best Original Articles



  Submit Articles
  Members Login
  Benefits
  Expert Authors
  Read Endorsements
  Editorial Guidelines
  Author TOS

  Terms of Service
  Ezines / Email Alerts
  Manage Subscriptions
  EzineArticles RSS

  Blog
  Forums
  About Us
  What's New
  Contact Us
  Article Writing Shop
  Advertising
  Affiliates
  Privacy Policy
  Site Map


Advanced Search


Would you like to be notified when a new article is added to the Software category?

Email Address:


Your Name:


Prefer RSS?
Subscribe to the
Software
RSS Feed:

QTP Script For Connecting to Database
Print This Article Ezine Publisher Send To Friends Add To Favorites Post A Comment Suggest Topic Report Author

QTP Script for connecting to MS Access.

Option Explicit

Dim con,rs

Set con=createobject("adodb.connection")

Set rs=createobject("adodb.recordset")

con.provider="microsoft.jet.oledb.4.0"

con.open"d:testdata.mdb"

rs.open"select*from emp",con

Do while not rs.eof

VbWindow("Form1").VbEdit("val1").Set rs.fields("v1")

VbWindow("Form1").VbEdit("val2").Set rs.fields("v2")

VbWindow("Form1").VbButton("ADD").Click

rs.movenext

Loop

The database we are using here is MS Access.Before running this script create a table in MS Acess.

In the above script I used table called "emp" and column names as "v1" and "v2".

"d:testdata.mdb" is path of the table which we created.

The main use of this script is to use testdata of table(which is in database) in the application.

In the above script we are passing values from database to Textboxes in Windows Application.

Similarly script for connecting to other 2 databases are

QTP Script for connecting to sqlserver.

Option Explicit

Dim con,rs

Set con=createobject("adodb.connection")

Set rs=createobject("adodb.recordset")

con.open"provider=sqloledb.1;server=localhost;

uid=sa;pwd=;database=testdata"

rs.open"select*from emp",con

Do while not rs.eof

VbWindow("Form1").VbEdit("val1").Set rs.fields("v1")

VbWindow("Form1").VbEdit("val2").Set rs.fields("v2")

VbWindow("Form1").VbButton("ADD").Click

rs.movenext

Loop

Script for connecting to oracle

Option Explicit

Dim con,rs

Set con=createobject("adodb.connection")

Set rs=createobject("adodb.recordset")

con.open"provider=oraoledb.1;server=localhost;

uid=scott;pwd=tiger;database=testdata"

rs.open"select*from emp",con

Do while not rs.eof

VbWindow("Form1").VbEdit("val1").Set rs.fields("v1")

VbWindow("Form1").VbEdit("val2").Set rs.fields("v2")

VbWindow("Form1").VbButton("ADD").Click

rs.movenext

Loop

This is the way u connect  to database in QTP and get the values from database.

For more QTP Scripts u can check http://www.funandknowledge.blogspot.com

SQL Queries in SQL Server,Oracle -http://www.sqlqueriescollection.blogspot.com

Lak

Article Source: http://EzineArticles.com/?expert=Snigdha_Lak

Other Recent EzineArticles from the Computers-and-Technology:Software Category:

Most Viewed EzineArticles in the Computers-and-Technology:Software Category (90 Days)

  1. The Benefits of the RegCure Software Product
  2. How to Delete The Total Security Virus From Your Computer - A Total Security Removal
  3. How to Remove Security Tool - Get Rid of Security Tool and Regain Your Safety
  4. How to Remove The Green Antivirus 2009 - Uninstall 'Green AV' Quick and Easy
  5. How to Remove Cyber Security - Uninstall Cyber Security and Get Rid of it Forever!
  6. Javascript Calendar - Add an Event Calendar to Your Website
  7. Fix Windows Vista Shut Down Issues - How to Fix Them in a Very Easy Way Instantly
  8. Follow These 5 Easy Steps - How to Speed Up Computer Instantly - Do the Steps & Speed Up in Minutes
  9. The Best and Simplest Way to Speed Up My Computer - How to Increase Computer Speed Massively
  10. 4 Things You Should Know How to Fix Windows XP Error Messages - Resolve Windows Error Made Easy
  11. Fix BSOD Problem - How to Fix the Blue Screen Physical Memory Dump Easily
  12. 3 Easy Ways How to Fix Bad Pool Caller Issue Instantly - Solving Bad Pool Problem
  13. 3 Steps to Speed Up My Computer - Make Your Computer Work Faster in Minutes!
  14. How to Remove Alpha Antivirus - The Easiest Alpha Antivirus Removal Available!
  15. How to Tweak Windows XP Speed? - Follow These 3 Steps on How to Increase Your Windows XP Speed Now

Most Published EzineArticles in the Computers-and-Technology:Software Category

  1. Workstation Optimizer - What is It? And Does it Work?
  2. How Do I Get Rid of a Trojan Virus From Your Computer? Best Tips to Protect Computer From Virus
  3. Need a Trojan Horse Remover? Remove Trojans Virus Easily and Effectively
  4. Internet Antivirus Pro Removal - 3 Top Ways to Protect Your Computer From Trojan Virus Instantly
  5. Trojan Virus Removal - 3 Steps How to Get the Trojan Virus Off My Computer Quickly
  6. Learn 5 Fast Steps Instructions of Removing Personal Antivirus From Your Computer
  7. 3 Fast Ways - How Do I Get Pav Exe off My Computer? What Should You Do?
  8. Remove PAV - 3 Top Tips How to Conduct A PAV Virus Removal
  9. How to Remove Google Redirect Virus? Use These Google Redirect Virus Fix Instructions to Fix Your PC
  10. How to Remove Antivirus System Pro - Follow These Instruction in 5 Minutes
  11. How Do I Get Rid of Personal AV Instantly? Remove it Now in Less Than 5 Minutes
  12. Google Redirect Virus Removal - 5 Steps How to Get Rid Of Google Redirect Virus Instantly
  13. 6 Easy Ways to Do Internet Antivirus Pro Removal - How to Remove Internet Antivirus Pro Instantly!
  14. How to Completely Remove Trojan Horse Instantly - Use This Trojan Horse Remover Now!
  15. How to Remove Crazy Trojan Horse Virus Quickly? Use Automatic Trojan Horse Removal to Get Rid of It

 

This article has been viewed 2,076 time(s).
Article Submitted On: December 24, 2008



© EzineArticles.com - All Rights Reserved Worldwide.