title: Reusing connection manager from SSIS script task
body: <p>In my SSIS package, I created <a href="https://www.tutorialgateway.org/ado-net-connection-manager-in-ssis/" rel="nofollow noreferrer">ADO connection manager</a>, so I have <code>MyAdoManager.conmgr</code> that has underlying connection named <code>MyServerName.MyDbName</code>.</p>
  <p>Now, I'm trying to <a href="https://stackoverflow.com/a/11867831/437393">use it</a> in the <code>Script Task</code> the way it's described in <a href="http://toddmcdermid.blogspot.com/2011/05/use-connections-properly-in-ssis-script.html" rel="nofollow noreferrer">some</a> manuals.</p>
  <pre><code>ConnectionManager cm;
  System.Data.SqlClient.SqlConnection sqlConn;
  System.Data.SqlClient.SqlCommand sqlComm;
  
  cm = Dts.Connections[&quot;MyAdoManager.conmgr&quot;]; // also tried &quot;MyServerName.MyDbName&quot;
  
  sqlConn = (System.Data.SqlClient.SqlConnection)cm.AcquireConnection(Dts.Transaction);
  sqlComm = new System.Data.SqlClient.SqlCommand(&quot;SELECT * FROM MyTable&quot;, sqlConn);
  sqlComm.ExecuteNonQuery();
  
  cm.ReleaseConnection(sqlConn);
  </code></pre>
  <p><strong>The issue</strong></p>
  <p>After executing package, I always get an exception &quot;Connection not found&quot;. How do I get access to the connection used by existing connection manager?</p>
  <p>What connection name should I use here <code>cm = Dts.Connections[&quot;...&quot;]</code>?</p>
  <p>Also, I saw some <a href="https://stackoverflow.com/a/9097343/437393">suggestions</a> that I need connection manager to the script box, but I don't have any connection related settings in the script editor in my SSIS.</p>