Ask a Question

Changing Server Login info

jashua
New Contributor

Changing Server Login info

I am currently trying to change the login info for my db checkpoints for a project.  All of my test data is on sql2008R2.  It is now time to switch my data over to SQL2012.  I probably will only be doing this every four years or so.  The code below seems to work with the following exception.  Every time my script finishes running my string returns to its original state.  Any help would be appreciated.

 

The code came from the following link:

https://community.smartbear.com/t5/TestComplete-General-Discussions/Variable-for-connection-string-o...

 

Here is my script.

 

function UpdateConnectionString()

//Obtain a collection of the DBTable elements using the aqObject.GetProperties method.

{

  var props = aqObject.GetProperties(DBTables);

    var prop;

    var tableName;

    var newConnectionString = "Provider=SQLNCLI.1;Password=csl123;Persist Security Info=True;User ID=cslinh;Initial     Catalog=UM0_DemoTestComplete;Data Source=JKM\\SQL2012";

  //If you use a project variable to keep the new connection string (for example, called   myConnectionString), use the following line instead:.

  //var newConnectionString = Project.Variables.myConnectionString;

 

    while (props.HasNext())

    {

    //Move to the next property

        prop = props.Next();

    //Obtain the table name

        tableName = prop.Name;

    //Use the eval function to assign a new value to the table's ConnectionString property

        eval("DBTables." + tableName + ".ConnectionString = newConnectionString");

     }

}

 

2 REPLIES 2
Marsha_R
Community Hero

Does your variable have a default value entered?  Try taking that out.


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
HKosova
SmartBear Alumni (Retired)

There's no need for eval:

DBTables[tableName].ConnectionString = newConnectionString;

 

But if you want to use eval, make sure to concatenate the variables and strings correctly and add inner quotes around the new connection string:

eval("DBTables." + tableName + ".ConnectionString = \"" + newConnectionString" + "\"");

Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
cancel
Showing results for 
Search instead for 
Did you mean: