Skip to main content

Setting the Connection String in a Package from a Variable

This snippet shows how to set the connection string of a connection referenced from a package with a package variable. The package variable is set from the parent package. Notice that the connection is declared under the Biml root node, and the connection string is set in the Connections node inside the Package node.

<Biml xmlns="http://schemas.varigence.com/biml.xsd">
<Connections>
<Connection Name="SourceConn" ConnectionString="Data Source=(local);Initial Catalog=SourceDb;Provider=SQLNCLI10.1;Integrated Security=SSPI;Auto Translate=False;" />
</Connections>
<Packages>
<Package Name="Load SorceTable" ConstraintMode="Linear" PackageSubpath="Staging_ETL" >
<Variables>
<Variable Name="DataSourceConnectionString" DataType="String" InheritFromPackageParentConfigurationString="DataSourceConnectionString"></Variable>
</Variables>
<Connections>
<Connection ConnectionName="SourceConn">
<Expressions>
<Expression PropertyName="SourceConn.ConnectionString">@[User::DataSourceConnectionString] </Expression>
</Expressions>
</Connection>
</Connections>
</Package>
</Packages>
</Biml>