Pergunta

I'm building a custom SSIS transformation data flow component and built a custom UI to manage my custom properties. My component has an additional ADO.net connection which I've created by overriding the ProvideComponentProperties method.

//New connection manager
            IDTSRuntimeConnection100 conn = this.ComponentMetaData.RuntimeConnectionCollection.New();
            conn.Name = "Central Store Connection";
            conn.Description = "ADO.NET Connection to the central Data Store";

This gives me a connection that I can set using a connections tab in the advanced editor. In my UI I have a combobox that binds in all ADO.net connection in the package:

 /// <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]);
                    }
                }
            }             
        }

Connections here are passed through from the Microsoft.SqlServer.Dts.Runtime.Connections connections in the initialize method of my UI class.

I want to be able to set the RuntimeConnectionCollection when the combobox selection has changed.

I've tried setting this like a like you would a custom metadata property but this doesn't work.

Foi útil?

Solução

You have to use the ConnectionManagerID on the RuntimeConnectionCollection.

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

            this.metaData.RuntimeConnectionCollection[0].ConnectionManagerID = ((ConnectionManager)val).ID;
        }

After using the ConnectionManagerID property everything works fine.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top