search
Japanese Chinese Nederlands Espanol Italiano Deutsch Francais Twitter Rss Feeds
MicrosoftArticlesForumsFAQs
C# .NET
VB.NET
Visual Studio .NET
ADO.NET
Xml / Xslt
VB 6.0
.NET CF
GDI+
LINQ
Deployment
Security
FoxPro
Silverlight / WPF
Entity Framework
RIA Services

Web ProgrammingArticlesForumsFAQs
JavaScript
ASP
ASP.NET
Web Services

Non-MicrosoftArticlesForumsFAQs
NHibernate
Perl
PHP
Ruby
Java
Linux / Unix
Apple
Open Source

DatabasesArticlesForumsFAQs
SQL Server
Access
Oracle
MySQL
Other Databases

OfficeArticlesForumsFAQs
Excel
Word
Powerpoint
Outlook
Publisher
Money

Operating SystemsArticlesForumsFAQs
Windows 7
Windows Server
Windows Vista
Windows XP
Windows Update
MAC
Linux / UNIX

Server PlatformsArticlesForumsFAQs
BizTalk
Site Server
Exhange Server
IIS

Graphic DesignArticlesForumsFAQs
Macromedia Flash
Adobe PhotoShop
Expression Blend
Expression Design
Expression Web

OtherArticlesForumsFAQs
Subversion / CVS
Ask Dr. Dotnetsky
Active Directory
Networking
Uninstall Virus
Job Openings
Product Reviews
Search Engines
Resumes

 

View Other C# .NET Posts   Ask New Question 
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);