Test case ID
Database1 Database2
------------------------------------------------------------------------------------------------------------------------
1 select count(*) TotalRecords
from select count(*) TotalRecords from
TableA where
abc='12' TableA where abc='12'
------------------------------------------------------------------------------------------------------------------------
2 select count(*) TotalRecords
from select count(*) TotalRecords from
TableB where
abc='12' TableB where
abc='12'
------------------------------------------------------------------------------------------------------------------------
3 select count(*) TotalRecords
from select count(*) TotalRecords from
TableC where
abc='12' TableC where
abc='12'
------------------------------------------------------------------------------------------------------------------------
Hi All,
I have 1 excel template like above containing 3 columns namely
TestcaseID, Database1,Database2 as shown above. col2 and col3 contains
queries from tables for each database resp.
What I want is to execute each queries in the sheet corresponding to
each testcaseID and then compare the result of two queries... i.e
queries contains Count(*) function so I want to compare the value of
the two queries for each testcase ID.
Similarly there are many testcases for which i need to perform the same operation.
Call RowCountValidation "RowCount"
Function RowCountValidation(strRowCountFile)
''Initialize Database Objects
Dim adoRecordSet1,adoRecordSet2
Dim adoConnection
Dim adoCommand
Dim conString
conString="Provider=SQLOLEDB.1;Password=1234;Persist Security Info=True;User ID=sa;Initial Catalog=AdventureWorks;Data Source=SHALABHDIXIT-PC"
'Set Database Objects
Set adoConnection=CreateObject("ADODB.Connection")
Set adoRecordSet1=CreateObject("ADODB.RecordSet")
Set adoRecordSet2=CreateObject("ADODB.RecordSet")
adoConnection.Open(conString)
DataTable.ImportSheet "C:\Test\"&strRowCountFile&".xls","Rowcount","Global"
strFileRowCount=DataTable.GlobalSheet.GetRowCount
MsgBox strFileRowCount
val1 = DataTable.Value("Database1",dtGlobalSheet)
val2= DataTable.Value("Database2",dtGlobalSheet)
Set adoRecordSet1=adoConnection.Execute(val1)
Set adoRecordSet2=adoConnection.Execute(val2)
fieldsCount1=adoRecordSet1.Fields.Count
fieldsCount2=adoRecordSet2.Fields.Count
MsgBox query &"fieldsCount1= " &fieldsCount1 &" fieldsCount2 = " &fieldsCount2
Do
For i=0 to fieldsCount1-1
Print adoRecordSet1.Fields(i).value & adoRecordSet1.Fields(i).Name
valueSet1=adoRecordSet1.Fields(i).Value
MsgBox valueSet1
adoRecordSet1.MoveNext
For j=0 to fieldsCount2-1
Print adoRecordSet2.Fields(j).value & adoRecordSet2.Fields(j).Name
valueSet2=adoRecordSet2.Fields(j).Value
MsgBox valueSet2
If valueSet1=valueSet2 Then
Reporter.ReportEvent micDone, "Data match success","Database matched successfully"
Else
Reporter.ReportEvent micDone, "Data match failure","Database NOT matched"
End If
Next
adoRecordSet2.MoveNext
Next
Loop until adoRecordSet1.EOF and adoRecordSet2.EOF
adoConnection.Close
Set adoConnection=nothing
End Function