I’m writing a Custom SSIS task that, as one of it’s functions, should execute a stored procedure on a database connection. I can’t seem to find any information about how this is done.
I’m using an ADO.NET Connection Manager to connect to the database and I wish to write my Task in C#.
What is the preferred way of executing SQL in a Custom SSIS task?
The answer to this depends somewhat on what connection manager you are using to connect to the database, however the general approach is the same:
Connectionsproperty of thePackageobject.AcquireConnectionmethod on the connection manager to obtain a connection to your database.This approach allows you to take advantage of the configuration and management of connections provided by SSIS.
For an ADO.NET connection manager, the following code can be used:
You will want some better error handling and I’m not sure about how to handle the lifespan of the connection, whether you should open it manually or dispose after use.
Good luck!