Forum Discussion

nwang66's avatar
nwang66
Contributor
15 years ago

Compare two DBTables objects

Hi, 

     I need to compare data from two different database servers. Both are SQL Server, but different connection strings. So I create two Stores | DBTables, say DBTables1 and DBTables2, then compare if records in DBTables1 are same as DBTables2. It works in most cases, sometimes it doesn't. If my SQL query doesn’t return any record, which is one of normal cases,  then the DBTables cannot be created. Is this configured in the Project Properties? Or should I use other way to do this test?



    Thanks a lot!



Nancy


1 Reply



  • Hi Nancy,






    Currently, the DBTable Checkpoint feature of TestComplete does not allow saving baseline data without any records. I have registered your request as a suggestion in our database.






    In the meantime, you can use the ADO extension to check whether there are any records recorded by a request.








    function testADORequest()


    {


      var Cmd = ADO.CreateADOCommand();


      Cmd.ConnectionString = "Driver={SQL Server Native Client 10.0};Server=myServer;Database=myDatabase; Uid=myUsername;Pwd=myPassword;";


      Cmd.CommandText = "SELECT * FROM USERS WHERE PEN_NAME = 'Nancy'";


      Cmd.CommandType = cmdText;






      var RecSet = Cmd.Execute();


      if (RecSet.EOF == true) {


        Log.Message("The recordset is empty");


      }


      else {


        Log.Message("The recordset contains items");


      }


    }