I have a database checkpoint in QTP (HP QuickTest Pro); this checkpoint works if I pass it a static query, but I need to be able to pass in parameters or build the query programatically. I also know how to query the database programatically from QTP, but don’t see a way to create a checkpoint based on its results.
Specifically, I want to cause a FAIL if the returned RecordCount = 0, and PASS if >= 1. I’m a Developer, not a Tester; and the QTP forums aren’t responding – Help me SO!
This is the code I tried — which works but lacks a Checkpoint:
Dim con, rs,strSQL, Param1, Param2 Param1 = DataTable('B', dtGlobalSheet) Param2 = DataTable('A', dtGlobalSheet) Set con=Createobject('ADODB.Connection') Set rs=Createobject('ADODB.recordset') rs.CursorLocation = 3 rs.CursorType =3 connSTR= 'Driver={SQL Server};Server=vsql0001;Database=DB0001;Dsn=myRegistryName' con.open connSTR strSQL= 'select Field1, Field2 from dbo.Table1 where Field1 in (select Field1 from dbo.Table2 where Param2 like '%'+Param2+'%' and active = 1) and (Field2 = ''+Param1+'' or Field2 like ''+Param1+' %' or Field2 like '%*'+Param1+'' or Field2 like '%*'+Param1+'*%')' rs.open strSQL, con msgbox rs.recordcount ' want the CP to go here rs.close con.close
Got it. I give it the static query and change it before it evaluates.