Ask a Question

How to implement SQL database validation in TestComplete?

Super Contributor

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?





Esteemed Contributor

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


What I do is use the ADO object (see 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.

Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Valued Contributor

Try using Database Checkpoints as explained here

Community Hero

Hi Mathijs,


Also, the whole HowTo|SQL branch ( contains a set of useful code samples.

  /Alex [Community Hero]
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
Showing results for 
Search instead for 
Did you mean: