Click here to Skip to main content
15,797,721 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I have the following codes/scripts in my Script Component in data flow in my SSIS package.
However when I try to execute it, it shows me the above error message as the title.
Below are my codes:

using System;
using System.Data;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;
using System.Data.SqlClient;

public class ScriptMain : UserComponent
    IDTSConnectionManager100 connMgr;
    SqlConnection sqlConn;
    SqlDataReader sqlReader;

    public override void AcquireConnections(object Transaction)
        connMgr = this.Connections.GsfConnection;
        sqlConn = (SqlConnection)connMgr.AcquireConnection(null); //error should happen here

    public override void PreExecute()
        SqlCommand cmd = new SqlCommand("EXEC usp_SSISPartNumber_Select " + "725", sqlConn);
        sqlReader = cmd.ExecuteReader();

    public override void CreateNewOutputRows()

    public override void Input0_ProcessInputRow(Input0Buffer Row)
        while (sqlReader.Read())
                Output0Buffer.NumberFamily = sqlReader.GetString(0);
                Output0Buffer.NumberInternal = sqlReader.GetString(1);
                Output0Buffer.ItemHeaderId = sqlReader.GetInt32(2);

    public override void PostExecute()

    public override void ReleaseConnections()

I know that the problem happens at the "AcquireConnection" method, but I have not idea on how to solve it. Any help would be appreciated. Thank you.

1 solution

We can't help you - we have no idea what datatype your manager.AcquireConnection is going to return.
So look at the intellisense for the method, and see what type it returns. If it's a generic type of some description then start by changing the code:
object o = connMgr.AcquireConnection(null);
And put a breakpoint on it. Run your code, Execute the line using single step, and look at what type of value is in "o".

Be we can't do any of that for you!
Share this answer
Jamie888 25-Nov-15 19:35pm    
I have give it a try by changing it to your suggestion sir but unfortunately, it still has error at it. Furthermore in data flow it does not support debugging which is a pain.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900