I have the following code written in SSIS Script The task for connecting to my SQL database:
ConnectionManager cm; System.Data.SqlClient.SqlConnection sqlConn; System.Data.SqlClient.SqlCommand sqlComm; cm = Dts.Connections["QUAHILSQ03"]; sqlConn = (System.Data.SqlClient.SqlConnection)cm.AcquireConnection(Dts.Transaction);
However, this line:
sqlConn = (System.Data.SqlClient.SqlConnection)cm.AcquireConnection(Dts.Transaction);
It returns the following exception:
{"It is not possible to pass a COM object of type" System .__ ComObject "to a class type of" System.Data.SqlClient.SqlConnection ". Instances of types that represent COM components cannot be assigned to types that do not represent COM components, but they can be passed to interfaces if the underlying COM component supports QueryInterface calls to the IID of the interface. " } System.Exception {System.InvalidCastException}
NealR source share