Forum Discussion

sdouglasb's avatar
sdouglasb
New Contributor
4 years ago
Solved

How do I use a variable for the connection string in keyword test db table variables in TestComplete

I created a project level variable as a string with the value being the connection string I want to use for database queries in all my keyword tests.  The idea being that this way I would only have to change the connection string in one place and it be changed for all queries in all my tests that use it.  This way I can easily run my tests in different environments without having to edit every single test first.

However, I can't seem to figure out how to use the connection string variable in my tests.

For example, in a keyword test, I:

1. click the Variables tab

2. right click then click New Item

3. select Type = DB Table

4. select data source type = Database Query

In the Specify Database Connection Settings window, it will not let me use a variable in the Connection field.

5. click the 3 dots at the right of the Connection field

In the Data Link Properties window, it will not let me use a variable in the Server Name field

6. manually populate connection fields

7. click OK

8. enter query into the Query Text field

9. click Finish

on the keyword test Variable tab, my variable is created, but when I try to edit the Default Value field replacing the connection string with a variable, it does not save.

 

Is it in any way possible to use a project level variable as the connection string for a keyword test DB Table variable?

 

7 Replies

  • The connection string for DB connections can only be parameterized via variables within script routines, currently not supported by the keyword test operations

  • Bake1r's avatar
    Bake1r
    Occasional Visitor

    I faced similar kind of issue last time, I am still searching for some proper solution tellthebell.