TestComplete and SQL databases - Restoring per test
Hi there,
Just looking at ways of implementing a way to restore a test SQL database back to it's original condition once a load of TestComplete tests run against it.
I have found this link but a little confused on how to implement it: https://community.smartbear.com/t5/TestComplete-Desktop-Testing/Restoring-SQL-db-quickly-through-TestComplete/m-p/120425/highlight/true#M6401
But then found this as well, again a little confused to implement it: http://raaviblog.com/how-to-restore-sql-database-in-testcomplete-using-javascript/
However another question I had was could we not run a BEGIN TRANSACTION before any test and then a ROLLBACK at the end of it? No tables are being created or dropped.
All help is appreciated!
Unfortunately it didn't however I was able to get some help from a developer within our company and have got the following working:
function TestProc() { var Qry; var con; // Create a query Qry = ADO.CreateADOQuery(); con = ADO.CreateADOConnection(); con.ConnectionString = "Provider=MSOLEDBSQL.1;User ID=XX;Password=XX;Initial Catalog=XXXXDB;Data Server=computer\\sqlserverinstance,1433;" con.CommandTimeout = 1000 con.LoginPrompt = false;
con.Open() Qry.ConnectionString = con.ConnectionString; Qry.SQL = "SELECT * FROM Users"; queryResult = Qry.FieldCount; // Closes the query con.Close(); }