I am having an issue programmatically setting connection strings.
Here is an overview of my project. I am using 2012 SSIS and have two connections in my connection managers (Source and Destination and both are OLE DB connections). I have multiple packages I want to run. Each of these packages only contain Execute SQL tasks. Each task I have the SQL Statement connection type set to OLE DB, the connection is Destination, the SQL Source Type is a File Connection, and the File Connection is a file located on my C drive that is a script file that I generate in my program.
I have these packages deployed on my server which is a 2012 instance. The source and destination connections are also on my server but on a 2008 R2 instance.
I loop through N number of databases. In each loop I can set the Connection String and IntialCatalog properties by executing a SQL statement:
DECLARE @var sql_variant = N'Data Source=MyServerName\SQL2008R2;Initial Catalog=DatabaseName1;Provider=SQLNCLI11.1;Integrated Security=SSPI;Auto Translate=False;'
EXEC [SSISDB].[catalog].[set_object_parameter_value] @object_type=20, @parameter_name=N'CM.Destination.ConnectionString', @object_name=N'MAC', @folder_name=N'MAC', @project_name=N'MAC', @value_type=V, @parameter_value=@var
This does work since I can open up the configure option on my project and see that the connection string and initial catalog values change while I am stepping through the program. (I didn't include the SQL for the initial catalog but it is similar to the connection string)
Now when I execute this through my program, I the following errors:
The connection "{9C2C8088-CE67-4D93-81B8-EC364D6E78D1}" is not found. This error is thrown by Connections collection when the specified connection element is not found.
Is there a way to update the package so the Execute SQL Tasks have an updated connection?
As a side note, if I open the packages in Visual Studio and modify the connections, the packages execute. It is when I try to programmatically change the connections and execute or if I try to execute the packages that are deployed on the server when it errors.
I did see this question and although it is similar, I think it varies enough to have a separate question. SSIS Connection not found in package. I have found a lot of great info here, just not what I am looking for yet.
Any help/advice is greatly appreciated!
Thanks
Mark