How to Compare two database tables by using QTP?Please give
me code details.



How to Compare two database tables by using QTP?Please give me code details...

Answer / 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

More QTP Interview Questions

What is synchronization? What are the ways you can synchronize?

0 Answers  


what are recovery management techiniques?

1 Answers  


Explain about the test fusion report of quicktest professional (qtp)?

0 Answers  


how do u manipulating INI, DLL and / or registry files in support of your test environment? actually what do u mean by INI and DLL or registry files. plzzz its urgent do answer

0 Answers  


can we test an windows application using qtp

1 Answers  






What if recovery scenarios is also failed for identify the alert ? (We are handling unexpected popup through recovery scenarios but if still recovery scenarios also failed than what should be the approach)

0 Answers   Tech Mahindra,


What is the extension of 'Log file' in QTP

3 Answers  


what are the Tools for version control?

3 Answers  


1) How will you associate SOR in Runtime? ( u had written 10 lines of code from 11th line u want associate what code u will write) 2) How will close n number of browser expect only one which is has to test? ( First tell me how will you identify how many browser are opened ) what logic u will use? 3) In web Table u want to click on link ( Link Name Mohamed ) you dont know in which row and column that link is there. how wil u identify and click on that link.

2 Answers  


How to change the screen name while running the test.

3 Answers   TCS,


What is your role and responsibilities in QTP with your current organization?

1 Answers   Oracle,


i'm testing the webpage with QTP, in this wabpage i have to choose the CV from the window, but QTP can't recognize the object, so i used the Low LEvel Recording, but every time i run the test, QTP go to halt when it gets to the Recorded part, any solution for that?( except puting delay in the script and manuall selecting, because i've did that)

0 Answers  


Categories