Wednesday, December 2, 2009

34. Database Connections:

We can connect to database & update data & Read data from database using Below Classes.
1. Adobd.Connection: we can use this class to establish the connection to the database.
2. Adodb.Command: we can use this class to execute any SQL statement like Insert, Update and delete Commands.
3. Adobd.Recordset: we can use this class to select the record from database.
By using Database connection we are applying the Multiple no of inputs to the Script.
We can apply the input by 3 ways.
· MS-Access.
· SQL Server.
· Oracle.


34.1. MS-Access:
By using MS-Access we are applying the multiple no of Inputs to check the functionality.
Step 1: Open the MS-Access.
Step 2: Create the Database by clicking on the New Button option in the Menu Bar.
Step 3: Select Blank Database at Right side of the MS-Access.
Step 4: File New Database dialog box opens, in the File Name field just enter the Database Name and click on Create.
Step 5: Database (Access 2000 file format ) dialog box opens.
Step 6: In that dialog box Double click on Create table by Entering Data to create a new data table in the database.
Step 7: Now Data Table opens, In the Field Row just Enter the Template name e.g. AgentName and Password.
Step 8: Then Enter the multiple number of inputs in the Table.
Step 9: Save the Table, and close the Database.
Step 10: Open the Test in the QTP.
Step 11: Enter the script as


E.g.: Set con=createobject ("adodb.connection")
Set rs=createobject ("adodb.recordset")
con.open "provider=microsoft.jet.oledb.4.0; data source=""
rs.open"select * from orders", con
While rs.EOF<>true
Dialog ("Login").WinEdit ("Agent Name :") .Set rs ("agent name")
Dialog ("Login").WinEdit ("Password :") .Set rs ("password")
rs.movenext
Wend

Step 12: Execute the Script to Analyse the Result.


34.2. SQL Server:
Through the SQL Server we are applying the multiple no of inputs for the application.
Step 1: Open the SQL Server.
Step 2: Create the Database and Create the Data table.
Step 3: Enter all the Templates and Inputs in the Data table.
Step 4: Open the Test in QTP.
Step 5: Enter the Script as


E.g.: Set con=createobject ("adodb.connection")
Set rs=createobject ("adodb.recordset")
con.open"provider=sqloledb.1; server= ; uid= ; pwd= ; database= "
rs.open"select * from orders", con
While rs.EOF<>true
Dialog ("Login").WinEdit ("Agent Name :") .Set rs ("agent name")
Dialog ("Login").WinEdit ("Password :") .Set rs ("password")
rs.movenext
Wend

Step 6: Execute the Script to analyse the Result.


34.3. Oracle:
Through the Oracle applying the multiple no of inputs for the application.
Step 1: Open the Oracle
Step 2: Create the Database and Create the Data table.
Step 3: Enter all the Templates and Inputs in the Data table.
Step 4: Open the Test in QTP.
Step 5: Enter the Script as


E.g.: Set con=createobject ("adodb.connection")
Set rs=createobject ("adodb.recordset")
con.open"provider=oraoledb.1; server= ; uid= ; pwd= ; database= "
rs.open"select * from orders", con
While rs.EOF<>true
Dialog ("Login").WinEdit ("Agent Name :") .Set rs ("agent name")
Dialog ("Login").WinEdit ("Password :") .Set rs ("password")
rs.movenext
wend

Step 6: Execute the Script to analyse the Result.

No comments:

Post a Comment