P. 1
DataBase Testing Using QTP

DataBase Testing Using QTP

|Views: 23|Likes:
Published by priyanka
DataBase Testing Using QTP
DataBase Testing Using QTP

More info:

Published by: priyanka on May 05, 2012
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

12/04/2012

pdf

text

original

‘Description ‘ This script write and read value on MS Access Database

' Notes: I created a junk.mdb in MS access with a Table Name = Emp. ' There are 3 columns: FirstName, LastName, & Designation. ' I created a DSN using ODBC. For details see screen shots at end of the file ' **************** QTP script start here Option Explicit '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '<<<<<<<<DECLARE AND INITIALZE>>>>>>>>> Dim FirstName, LastName, Designation Dim oRst, oConn, strSql, x '<<<<<<<<<CREATE THE CONNECTION AND RECORDSET OBJECT>>>>>>>> set oConn = CreateObject ("ADODB.Command") set oRst = CreateObject ("ADODB.RecordSet") oConn.ActiveConnection = "dsn=" & "CrashTesting" '''CrashTesting is the name of DSN ' '''<<<<<<<<DEFINE THE 1st "WRITE" SQL STRING>>>>>>>>>>> strSql = "INSERT INTO Emp (FirstName, LastName, Designation) VALUES ('Ramana', 'Midde', 'CEO')" oConn.CommandText = strSql set oRst = oConn.Execute '''<<<<<<<<DEFINE THE 2nd "WRITE" SQL STRING>>>>>>>>>>> x = "N" '''Used to enter a variable thru a DIM variable strSql = "INSERT INTO Emp (FirstName, LastName, Designation) VALUES ('Madhu', 'Tummala', 'Test Manager')" oConn.CommandText = strSql set oRst = oConn.Execute '''<<<<<<<<DEFINE THE 3rd "READ" SQL STRING>>>>>>>>>>> strSql = "Select * from Emp ORDER by FirstName, LastName" oConn.CommandText = strSql set oRst = oConn.Execute '''<<<<<<<< "READ" thru the ResultSet>>>>>>>>>>>

'''' THis will read thru the RecordSet until EOF Do While NOT oRst.EOF FirstName = oRst.Fields("FirstName") LastName = oRst.Fields("LastName") Designation = oRst.Fields("Designation") MsgBox FirstName MsgBox LastName MsgBox Designation oRst.MoveNext Loop '<<<<<<<<<CLEANUP>>>>>>>>> oRst.Close Set oRst = Nothing ' **************** QTP script start end here

' Create a MS access database name junk.mdb with a Table Name = Emp ' DSN Setup ' Go to '<START>, <RUN>, 'enter "odbcad32.exe" <OK>

Click on Add and create new DSN name “CrashTesting” Select “CrashTesting” and click on Configure

Click on Select and point to your junk database and click OK

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->