Forum Discussion

ekiza23's avatar
ekiza23
Contributor
12 years ago

Compare 2 DBs with DBTables and Compare and Check methods.

Hi all,



I was looking forward to use the DBTables Stores to compare the contents of 2 databases and I was thinking of something like:



---------------------------------------------------------------------------------

DBTables.InvoiceHeader.ConnectionString = strConnectionToDB1

//Update the content of the Store with data from DB1

????



DBTables.InvoiceHeader.ConnectionString = strConnectionToDB2

//Verify that Store data with data from DB2

DBTables.InvoiceHeader.Check


---------------------------------------------------------------------------------



I found this article http://support.smartbear.com/viewarticle/30586/ where it says:

---------------------------------------------------------------------------------

Updating Checkpoints at Runtime




TestComplete lets you update the contents of DBTable elements stored in the DBTables collection directly from your tests. For this purpose, use the Compare method of the DBTable object in your test. Usually, this method is used to compare the database contents against stored values, but it can also replace the values stored in the element with the values retrieved from the database instead of comparing them. To activate this behavior, enable the Update DBTable elements option in the Stores Options dialog. 

---------------------------------------------------------------------------------



So I thought that if I activated this in the options I could do



---------------------------------------------------------------------------------

DBTables.InvoiceHeader.ConnectionString = strConnectionToDB1

//Update the content of the Store with data from DB1

DBTables.InvoiceHeader.Compare



DBTables.InvoiceHeader.ConnectionString = strConnectionToDB2

//Verify that Store data with data from DB2

DBTables.InvoiceHeader.Check


---------------------------------------------------------------------------------



It wasn't working, the check method seemed to update the data too ...

So I looked further in the documentation and found this other article http://support.smartbear.com/viewarticle/28985/



---------------------------------------------------------------------------------


Updating Values With the Compare and Check Methods


You can also update the contents of the DBTable elements by calling the Compare method of the DBTable object. Usually this method is used to compare the database contents against the stored values, but it can also replace the values stored in the element with the values retrieved from the database instead of comparing them. To activate this behavior, enable the Update DBTable elements option in the Stores Options dialog. When this option is enabled, the method will retrieve data from the database specified by the DBTable element’s properties. This element is the one you called the Compare method for, and save the retrieved data to.

---------------------------------------------------------------------------------



It seems that it says the same, but the title suggests that the Check method also updates the Store.


So, I am a little confused.



Is there a way of changing the Update DBTable elements option from the scripts so I can do something like: ???



---------------------------------------------------------------------------------

Update DBTable elements = true

DBTables.InvoiceHeader.ConnectionString = strConnectionToDB1

//Update the content of the Store with data from DB1

DBTables.InvoiceHeader.Compare



Update DBTable elements = false

DBTables.InvoiceHeader.ConnectionString = strConnectionToDB2

//Verify that Store data with data from DB2

DBTables.InvoiceHeader.Check


---------------------------------------------------------------------------------





Is this the normal behavior of the Check and Compare methods?



Is there a clean way of doing what I am trying to do or I am bound to create specific queries for each table I want to compare between these 2 databases?



Thanks all for your help.


No RepliesBe the first to reply