Forum Discussion

Sjef's avatar
Sjef
Occasional Contributor
3 years ago
Solved

Use Variables in the sql connectionstring

Hi there, I'm using 2 environments and 2 databases: 1 to create the testcases and 1 to execute them I want to check the results with DBTables Custom queries (SSMS) and I have i.e. next connect...
  • rraghvani's avatar
    3 years ago

    It's not possible within that dialog. However you can use ADO Object and create your own connection string using variables e.g.

    function ADOExample()
    {
        var AConnection = ADO.CreateConnection();
        var dbServer = "Server1";
        var dbName = "ALPHA";
        AConnection.ConnectionString = "Provider=MSOLEDBSQL19.1; Integrated Security=SSPI; Persist Security Info=False; Initial Catalog=" + dbName + "; Data Source=" + dbServer + "; Use Encryption for Data=False;";
        AConnection.Open();
       
        // Do something
       
        AConnection.Close();
    }