How to Compare two database tables by using QTP?Please give
me code details.
Answer Posted / jagathi
'Get Two different data from two different Tables and
compare it;
'Two different Database and check their values.
' First Table Name - -> EmpTable
' Second Table Name ---> DeptTable
'Database ---> MS Access
' First Table Connection
Dim conn,rs
Set conn=createobject("adodb.connection")
Set rs=createobject("adodb.recordset")
conn.provider="microsoft.jet.oledb.4.0"conn.open"C:\db1.mdb"
' creating an object for the recordsetset
rs =CreateObject("ADODB.recordset")
' DB Query for selecting all the records available from
EmpTable
rs.open "select * from EmpTable",conn
' Adding Headings
datatable.GetSheet(1).addparameter "EMPLOYEE NO","
"datatable.GetSheet(1).addparameter " NAME","
"datatable.GetSheet(1).addparameter "DESIGNATION","
"datatable.GetSheet(1).addparameter " ADDRESS",""row=1
' Loop for each records
Do While not rs.EOF
datatable.SetCurrentRow(row)
datatable.Value("EMPLOYEE_NO",1) = rs.fields("EmpNo")
datatable.Value("NAME",1)=rs.fields("EmpName")
datatable.Value("DESIGNATION",1)=rs.fields("Designation")
datatable.Value("ADDRESS",1)=rs.fields("Address")
val1 = datatable.Value("NAME",1)row=row +1rs.movenext loop
' Second Table Operation
set rs1 =CreateObject("ADODB.recordset")
'DB Query for selecting all the records available from
DeptTable
rs1.open "select * from DeptTable",conn
datatable.GetSheet(1).addparameter "EMPNO_Dept",""
datatable.GetSheet(1).addparameter "EMPNAME_Dept",""
datatable.GetSheet(1).addparameter "DEPTNAME_Dept",""
' Assigning values from First row
row=1
do While not rs1.EOF
datatable.SetCurrentRow(row)
datatable.Value("EMPNO_Dept",1)=rs1.fields("EmpNo")
datatable.Value ("EMPNAME_Dept",1)=rs1.fields("EmpName")
datatable.Value("DEPTNAME_Dept",1)=rs1.fields("DeptName")
row=row +1rs1.movenextloop
' Create one more Column called ResultColumn
DataTable.GetSheet("Global").AddParameter"ResultColumn",""
cnt=DataTable.GetRowCount
For i=1 to cnt
DataTable.SetCurrentRow(i)
OldVal=DataTable.Value("NAME","Global")
NewVal = DataTable.Value("EMPNAME_Dept","Global")
' Comparing two NAME fields
If OldVal = NewVal Then
DataTable.Value("ResultColumn","Global") = oldVal
Reporter.ReportEvent micPass, "P","The Names Fields are
Equal "
else Reporter.ReportEvent micFail,"F","The Names Fields are
Not Equal"
End If
Next
Is This Answer Correct ? | 2 Yes | 2 No |
Post New Answer View All Answers
How to export quicktest professional (qtp) results to an .xls file?
I am in .Net development for past 3.5 years and want to enter in to automated testing and learn QTP. For this I need some good tutorial for beginners. I will be really greatful if any one has and they can send it to me on this address- ruchidureja@gmail.com
what is meant by Implicit and explicit requirements?
how to download mercury qtp9.2 ny internet ?
Where can I find and view run-time data table?
Hi frnds, does anybody know if there is anything called "thin point" or something in qtp? thanks in advance.
how will load the object during runtime?
Explain the views in the QTP GUI?
Write a QTP script to enter a keyword in to Google search engine?
How does qtp identify objects in the application?
Is it possible to split an action? How?
any body plz send health care domain project to me with explanation any two modules on that project. mail_id: ranjith_99reddy@yahoo.co.in
If there is a change in the object type eg: A button is changed as link, 1. How to edit that in the shared object repository. 2.What options are available to edit the object within shared object repository other than copy from loca; 3.What would be the effect of the change in Coded Scripts within QTP and Functions stored in .vbs file which are loaded and used in QTP
in qtp if we record a object and we record the object using virtual wizard then by which way the object is recognized that means recorded
How many ways we can parameterize data in quicktest professional?