How to execute a SQL insert from TC 9
function qaCreatePrenatalHxFolder()
{
var sql_statement = "select * from dbo.TRK_TrackCategory where TrackCategory_Code = 'Prenatal hx'";
var Qry;// Create a query
Qry = ADO.CreateADOQuery();
Qry.ConnectionString = "Driver={SQL Server};Server=" + dbServer + ";Database=" + dbName + "; Trusted_Connection=True;";
Qry.SQL = sql_statement;
Qry.Open(); // Execute the query
var tmpCount = Qry.RecordCount;
Qry.Close(); // Closes the query
//does the Prenatal folder already exist?
if (tmpCount == 0)
{
// No, create it
Qry = ADO.CreateADOQuery();
Qry.ConnectionString = "Driver={SQL Server};Server=" + dbServer + ";Database=" + dbName + "; Trusted_Connection=True;";
var sql_statement = aqFile.ReadWholeTextFile("Q:\\Insert_Prenatal_HX.sql", aqFile.ctANSI);
Qry.SQL = sql_statement;
Qry.Open(); // Execute the query
var tmpCount = Qry.RecordCount;
Qry.Close(); // Closes the query
}
}
//END OF FUNCTION qaCreatePrenatalHxFolder
It works, but TestComplete complains and terminates - as shown in the attached file - because the "Stop on error" attribute is set. I tried to find ways to reset Stop on error programmatically, but it is read-only apparently settable only from the project properties GUI of TestComplete.
How do I get my script to execute and continue?
Thanks.