I am developing a custom SSIS task for running sql task. But it fails with error - I'm trying to set the resultsetbinding for some parameters , to be used by next task in workflow.
Error: 0xC0014054 at CustomSSISTask: Failed to lock variable "User::id" for read access with error 0xC0010001 "The variable cannot be found. This occurs when an attempt is made to retrieve a variable from the Variables collection on a container during execution of the package, and the variable is not there. The variable name may have changed or the variable is not being created.".
Error: 0xC002F210 at CustomSSISTask, Execute SQL Task: Executing the query "SELECT id FROM sysobjects WHERE name = 'sysrowsets..." failed with the following error: "Failed to lock variable "User::id" for read access with error 0xC0010001 "The variable cannot be found. This occurs when an attempt is made to retrieve a variable from the Variables collection on a container during execution of the package, and the variable is not there. The variable name may have changed or the variable is not being created.".
". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
Warning: 0x80019002 at CustomSSISTask: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED. The Execution method succeeded, but the number of errors raised (3) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.
Task failed: CustomSSISTask
Here is the code sample I'm trying ,
public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser,
IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)
// Add the SQL Task
Package package = new Package();
Microsoft.SqlServer.Dts.Runtime.Variable variable = package.Variables.Add("id", false, "User", 0);
// Get the task host wrapper
TaskHost taskHost = package.Executables as TaskHost;
// Get the task object
ExecuteSQLTask task = taskHost.InnerObject as ExecuteSQLTask;
// Set core properties
task.Connection = connections.Name;
task.SqlStatementSource = "SELECT id FROM sysobjects WHERE name = 'sysrowsets'";
task.SqlStatementSourceType = SqlStatementSourceType.DirectInput;
// Add result set binding, map the id column to variable
IDTSResultBinding resultBinding = task.ResultSetBindings.Add();
//IDTSResultBinding resultBinding = task.ResultSetBindings.GetBinding(0);
resultBinding.ResultName = "variable";
resultBinding.DtsVariableName = variable.QualifiedName; //"User::id";
task.Execute(connections, variableDispenser, componentEvents, log, transaction);
catch (Exception ex)
throw new ArgumentException(ex.Message);
It doesnt throw any exception but custom task fails.
Later I will be also using parametersetbindings to pass some input parameters to this task , since I'm stuck for out param - blocked moving ahead.