| 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. |
| Reply Reply Using Power Editor |
| |
| |
Rank |
Winnings |
Points |
| November |
0 |
$0.00 |
0 |
| October |
0 |
$0.00 |
0 |
|
|
|
|
|
|
|
| Doesn't make sense to me either |
| Peter Bromberg replied on 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. |
| Reply Reply Using Power Editor |
| Peter Bromberg is a C# MVP, MCP, and .NET expert who has worked in banking, financial and telephony for over 20 years. Pete focuses exclusively on the .NET Platform, and currently develops SOA and other .NET applications for a Fortune 500 clientele. Peter enjoys producing digital photo collage with Maya,playing jazz flute, the beach, and fine wines. You can view Peter's UnBlog and IttyUrl sites. Please post questions at forums, not via email! |  |
|
| |
Rank |
Winnings |
Points |
| November |
0 |
$0.00 |
0 |
| October |
0 |
$0.00 |
0 |
|
|
|
|
|
|
| PS - I have gotten this error |
| Peter Bromberg replied on 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); |
| Reply Reply Using Power Editor |
| Peter Bromberg is a C# MVP, MCP, and .NET expert who has worked in banking, financial and telephony for over 20 years. Pete focuses exclusively on the .NET Platform, and currently develops SOA and other .NET applications for a Fortune 500 clientele. Peter enjoys producing digital photo collage with Maya,playing jazz flute, the beach, and fine wines. You can view Peter's UnBlog and IttyUrl sites. Please post questions at forums, not via email! |  |
|
| |
Rank |
Winnings |
Points |
| November |
0 |
$0.00 |
0 |
| October |
0 |
$0.00 |
0 |
|
|
|
|
|
|
|
|