I am new to SSIS script task, I tried the below code to run a sql query in SSIS script task but I am end up with an error.
ConnectionManager cm = Dts.Connections["oledb"];
IDTSConnectionManagerDatabaseParameters100 cmParams = cm.InnerObject as IDTSConnectionManagerDatabaseParameters100;
OleDbConnection sqlConn = cmParams.GetConnectionForSchema() as OleDbConnection;
ErrorMessage:
Unable to cast COM object of type 'System.__ComObject' to class type 'System.Data.SqlClient.SqlConnection'. Instances of types that represent COM components cannot be cast to types that do not represent COM components; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface
I am trying to find DB Server name and try to assign the value to $Project::variable using Script task.
Is there anyway I can do this.
Thanks in advance.