Size property has an invalid size of 0
If you are using Dapper, you have passed in a null value for the parameter, where the expected input was a string.
To find the offending value and it's parameter, inspect at the Dapper DynamicParameters object during a debug session and open the parameters being index referred to.
Yes, have to define the length for varchar
/ nvarchar
data type like below.
cmd.Parameters.Add("@Description", SqlDbType.VarChar, 150).Direction =
ParameterDirection.Output;
You need to define a length when specifying the varchar
parameter:
SqlParameter job1 = cmd2.Parameters.Add("@job", SqlDbType.VarChar, 50);
You should use the same length as defined in your SQL Server stored procedure.
And btw: if your stored procedure also has no length defined (something like @job VARCHAR OUTPUT
) - then you've defined a varchar
string of 1 character length ......