Click here to Skip to main content
15,884,353 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SSIS how to set connection string dynamically from a config file
Posted

Create your variables in the Variable tab, mine are ProjectServer (String), DBName (String)

Create your DB Connection Object connecting directly to the actual Server and Database...Test your Connection

Right Click on the Connection Object and Select Properties
In the Properties Window Select Expressions by clicking the grey box with 3 dots ...
Select ConnectionString from the dropdown in the 1st column, then click the grey box with 3 dots.

In the Expression Editor that opens enter the following: "Data Source=" + @[User::ProjectServer] + ";Initial Catalog=FinancialProcessing;Integrated Security=True;"

Refer the links below:
Dynamic Connection Strings in SSIS[^]
Dynamic Database Connection using SSIS ForEach Loop Container [^]



Hope it helps.
--Amit
 
Share this answer
 
My solution is:
insert a [Script Task], and in script task editor you can get connection manager from Dts as follow:
ConnectionManager cm = Dts.Connections["YOUR_CONNECTION_NAME"] as ConnectionManager;
then you can change connection string dynamic as follow:
cm.ConnectionString="Provider=XXX;Data Source=XXX;User ID=XXX;Password=XXX;Initial Catalog=XXX";

Hope useful for you.

PS:
When I try Expression Editor, it always show me error, Does somebody can describe how to do?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900