C# C通过自定义UI设置SSIS自定义数据流组件的自定义连接

C# C通过自定义UI设置SSIS自定义数据流组件的自定义连接,c#,ssis,connection,components,C#,Ssis,Connection,Components,我正在构建一个自定义SSIS转换数据流组件,并构建了一个自定义UI来管理我的自定义属性。我的组件有一个额外的ADO.net连接,我通过重写ProvideComponentProperties方法创建了该连接 //New connection manager IDTSRuntimeConnection100 conn = this.ComponentMetaData.RuntimeConnectionCollection.New(); conn.Na

我正在构建一个自定义SSIS转换数据流组件,并构建了一个自定义UI来管理我的自定义属性。我的组件有一个额外的ADO.net连接,我通过重写ProvideComponentProperties方法创建了该连接

//New connection manager
            IDTSRuntimeConnection100 conn = this.ComponentMetaData.RuntimeConnectionCollection.New();
            conn.Name = "Central Store Connection";
            conn.Description = "ADO.NET Connection to the central Data Store";
这为我提供了一个连接,我可以使用高级编辑器中的“连接”选项卡设置该连接。在我的UI中,我有一个组合框,可以绑定包中的所有ADO.net连接:

 /// <summary>
        /// Initialises the connections combobox only adding ADO.Net connections
        /// </summary>
        private void initialiseConnections()
        {
            if (connections != null)
            {
                for (int i = 0; i < connections.Count; i++)
                {
                    if (connections[i].CreationName.ToLower().Contains("ado.net"))
                    {
                        comboConnections.Items.Add(connections[i]);
                    }
                }
            }             
        }
此处的连接通过my UI类的initialize方法中的Microsoft.SqlServer.Dts.Runtime.Connections传递

我希望能够在组合框选择发生更改时设置RuntimeConnectionCollection


我尝试将其设置为自定义元数据属性,但这不起作用。

您必须在RuntimeConnectionCollection上使用ConnectionManagerID

  private void comboConnections_SelectedIndexChanged(object sender, EventArgs e)
        {
            var val = comboConnections.SelectedItem;

            this.metaData.RuntimeConnectionCollection[0].ConnectionManagerID = ((ConnectionManager)val).ID;
        }
使用ConnectionManagerID属性后,一切正常