This post is to show how to use ADO connection in SSIS Script Component. At the same time, this is what myself always forget.
Bear in mind, I never successfully using OLEDB connection for this. I only successfully using this with ADO.NET connection.
Before going into the Script Editor make sure you create a Connection Manager for your Script Component.
![SSIS using ADO connection manager for Script Component]()
Open your Script Editor in Script Component (inside the Data Flow normally) by double clicking in. In the root area outside any method, I declared the following.
IDTSConnectionManager100 ConMgr;
object Targetconnection;
{
ConMgr = this .Connections.ConnectionBlock;
Targetconnection = this .Connections.ConnectionBlock.AcquireConnection( null );
SqlConn = Targetconnection as SqlConnection ;
}
Bear in mind, I never successfully using OLEDB connection for this. I only successfully using this with ADO.NET connection.
Before going into the Script Editor make sure you create a Connection Manager for your Script Component.

Open your Script Editor in Script Component (inside the Data Flow normally) by double clicking in. In the root area outside any method, I declared the following.
IDTSConnectionManager100 ConMgr;
object Targetconnection;
In between PreExecute and PostExecute methods, insert the follow AcquireConnections method. Sure there are other way to do this.
public override void AcquireConnections( object Transaction){
ConMgr = this .Connections.ConnectionBlock;
Targetconnection = this .Connections.ConnectionBlock.AcquireConnection( null );
SqlConn = Targetconnection as SqlConnection ;
}
You do not need to SqlConn.Open() to open the connection if you are utilizing the Connection Manager.