It is possible for us to create and manage Connection String at run time by using SqlConnectionStringBuilder class, So we can change connectionstring at any time.
Example Code :
SqlConnectionStringBuilder ConnBuild = new SqlConnectionStringBuilder();
ConnBuild.DataSource = "SQLExpress";
ConnBuild.ConnectTimeout = 1000;
ConnBuild.IntegratedSecurity = true;
ConnBuild.IntegratedSecurity = false;
ConnBuild.UserID = "Indrajeeth";
ConnBuild.Password = "Indrajeeth";
Some important properties of connectionstringbuilder class
Used for returning or setting name of the database related with the connection.
sets or returns false - indicating user-id and password is specified. and sets or returns false when current windows account credentials are used for authentication
Used for returning or setting user ID while connecting to SQL Server.
Gets or sets the password for the SQL Server account.
Used for setting or returing the time span (in seconds) for waiting connection to the server before terminating.
Used for setting or returing the name or network address for connecting of the instance of SQL Server.
Returns or sets Boolean value for specifing whether SQL Server uses SSL encryption for all data sent between the client and server (applicable only when the server has a certificate installed.)