'======================================== Function zSql_CountRows(sDsn,sSql) 'This function gets the number of rows satisfying a query 'NOTE - I could use COUNT in the query, but QTP sometimes has trouble with it Dim oCon, oRec Set oCon=CreateObject("ADODB.Connection") Set oRec=CreateObject("ADODB.Recordset") oCon.Open ("DSN=" & sDsn) oRec.Open sSQL,oCon If oRec.Eof Then zSql_CountRows = 0 Else zSql_CountRows = oRec.RecordCount End If oRec.Close oCon.Close Set oRec=Nothing Set oCon=Nothing End Function '========================================