Forum Discussion

mgroen2's avatar
mgroen2
Super Contributor
7 years ago

How to implement SQL database validation in TestComplete?

I want to use TestComplete to validate the results in an SQL database. Can I use TestComplete to connect to the MSSQL database, "fire" a querie to it, and validate on the results of the querie (which contains dynamic values).

 

If so, how to implement this? Can anyone help me with tips, best practices?

 

Thanks,

Mathijs

 

3 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    This is a regular task for us in our automation work.

     

    What I do is use the ADO object (see https://support.smartbear.com/testcomplete/docs/reference/program-objects/ado/index.html) to create connections and queries to our SQL database.  The link provides some basic examples as to how to implement the objects.  Your code may end up being more complex depending upon what you need to do.

     

    I have an extension (see my signature for the link) that encapsulates some of this for easy of use.  This code simply fires the queries.  Doing the comparison is simply writing "if-then" logic to compare the result of the query with the expected values.  The expected values, if dynamic, should still be attainable in your automation.  You've created the data in the first place during the course of the automation so you should be able to construct the expected values in code.