I recently implemented a solution to take an SSIS package and reconfigure the connection strings of the package using VB.net. The code is quite simple:
Const packageLocation As String = "C:\mylocation"
Dim app As New Application
Dim pkg = app.LoadPackage(packageLocation, Nothing)
pkg.Connections.Item(0).ConnectionString = "Data Source=MySource"
I need to write the same piece of code in C# because that is the native language of our QA team, however I can’t seem to be able to access the Item property:
const string PackageLocation = @"C:\MyLocation";
Application app = new Application();
Package pkg = app.LoadPackage(PackageLocation, null);
pkg.Connections.Item(0).ConnectionString = "Data Source=Mysource";
I am not understanding why I cannot access Connections.Item in the C# version of my code, yet I can with the VB version. What am I doing wrong?
In C#, the array syntax uses square brackets:
Or, since
Itemappears to be the default indexer for theConnectionsclass, just leave it out entirely: