sriram_sig
6 years agoContributor
How to make TestComplete execute custom sql queries with a variable name in where condition
I'm trying to add Database checkpoint by specifying a custom sql query like
Select * from Table1 where EmployeeID = id
In the previous step i fetch the value from the UI and store it in the id variable. But when i execute the test
DBTables.CheckNotification.RowCount
it is fetching the count of all the records in the table, rather than the specific record with the id. the previous line in the code to fetch the id from UI is working good
What method are you using to connect to SQL ? The syntax for a SQL query in ADO for example looks different than the SQL query you would use in a standard SQL and it may be that your query isn't sending the parameter correctly.
So for example your ADO command would specify the query as follows:
var ADOConnection = ADO.CreateConnection();
//Configure the ADOConnection var ADOCommand = ADO.CreateCommand();
//Configure the ADOCommand
ADOCommand.CommandText='select * from Table1 where Employeeid=? and EmployeeName=?'; //Here's the important bit: ADOCommand.Parameters.Item(0) = employeeIDValue; ADOCommand.Parameters.Item(1) = emplayeeNameValue; var RecordSet = ADOCommand.Execute(); //etc...