| The SqlParameterCollection only accepts non-null |
| Jim Tanner posted at Saturday, November 13, 2004 12:08 AM |
Hi,
I'm the guy having problems adding parameters to my SP.
I tried out:
command.Parameters.Add(new SqlParameter("@role", SqlDbType.Int).Value= 0);
and get error:
The SqlParameterCollection only accepts non-null SqlParameter type objects, not String objects.
Tried to google it and couldn't find anything. This one doesn't make sense. |
 |
|
|
| |
| Doesn't make sense to me either |
| Peter Bromberg replied at Saturday, November 13, 2004 8:14 AM |
 | SqlDbType is an enumeration, and ".Int" is one of them. I would try breaking this up - creat the parameter, type and direction , then assign the .Value=0 later.
Only other thing I can think of is you may be calling the wrong execute method of your Command object - ExecuteNonQuery instead of ExecuteScalar, for instance. Stuff like this has been known to generate unusual exception messages. |
 |
| |
| PS - I have gotten this error |
| Peter Bromberg replied at Saturday, November 13, 2004 12:57 PM |
 | this is an approach that takes care of it:
SqlParameter parm1 = new SqlParameter("@Beginning_Date",SqlDbType.DateTime );
parm1.Value = myDateTimeVariable;
command.Parameters.add(parm1); |
 |
| |
|
|