When I call the SSISDB catalog.set_execution_parameter_value stored proc to set parameters for the execution of my project, It blows up on a boolean parameter with
The data type of the input value is not compatible with the data type of the 'Boolean'
I tried using string and object with "False" or "1" value. Is there a way to pass a boolean to this proc from c#?
SOLUTION:
SqlCommand cmd = new SqlCommand("catalog.set_execution_parameter_value", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@execution_id", this.ExecutionID);
cmd.Parameters.AddWithValue("@object_type", ParamReference);
cmd.Parameters.AddWithValue("@parameter_name", ParamName);
SqlParameter p = cmd.Parameters.Add("@parameter_value", SqlDbType.Variant);
switch (ParamType)
{
case "String" :
p.Value = ParamValue;
break;
case "Int32" :
p.Value = Int32.Parse(ParamValue);
break;
case "Int64" :
p.Value = Int64.Parse(ParamValue);
break;
case "Boolean" :
p.Value = bool.Parse(ParamValue);
break;
}
cmd.ExecuteNonQuery();
From a pure TSQL perspective, the mechanism for setting a package parameter would look like
DECLARE @var0 bit = 0;
EXEC [SSISDB].[catalog].[set_execution_parameter_value]
@execution_id
, @object_type = 30
, @parameter_name = N'GoFast'
, @parameter_value = @var0;
AddWithValue can be tricky as it attempts to infer the correct data type and sometimes it doesn't go so well. There's an informative chart with Specifying Parameter Data Types on MSDN. If you rework your C# to explicitly set the data type and then assign a value, does that resolve the issue?
OleDbParameter parameter = cmd.Parameters.Add("@parameter_value", OleDbType.Variant);
parameter.Value = ParamValue;