Forum Discussion

sriram_sig's avatar
sriram_sig
Contributor
5 years ago
Solved

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 va...
  • RUDOLF_BOTHMA's avatar
    5 years ago

    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...