JessyEzzy
asked on
Setting the paramter size for a SqlParameter
I have this question about whether or not it's prefered to set the size of a SqlParamter.
I usually do something like this:
SqlCommand cmd = new SqlCommand(StoredProcName, Connection );
cmd.Parameters.Add("@SomeP aramter", SqlDbType.NVarChar).Value = SomeValue;
Is it recommended that I set the size of the paramter like this:
cmd.Parameters.Add("@SomeP aramter", SqlDbType.NVarChar, 100).Value = SomeValue;
or it's the same? And also, if the paramter is NText how would I set the size for it?
Thanks in advance
I usually do something like this:
SqlCommand cmd = new SqlCommand(StoredProcName,
cmd.Parameters.Add("@SomeP
Is it recommended that I set the size of the paramter like this:
cmd.Parameters.Add("@SomeP
or it's the same? And also, if the paramter is NText how would I set the size for it?
Thanks in advance
if you do not set the size explicitely, it will be "set" implicitely by the value you assign to the parameter.
ASKER
Set implicitly at which stage? And does setting or not setting the size affects performance?
Thanks
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks