Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Ported Sproc to Text sql, how to set defaults?

Author  Topic 

sql777
Constraint Violating Yak Guru

314 Posts

Posted - 2008-07-22 : 15:36:26
Hi,
I basically took the sproc code and put it inside a string, and I am calling the sql now from ADO.NET and not from a sproc now (because I have to be able to do dynamic order by's and ASC/DESC and I can't do that in a sproc w/o doing IF's etc).

In my sproc, I did this in the beginning:

@categoryid INT = NULL,
@userID INT = NULL


Now in my sql that I'm calling directly from ADO.NET, I can't set defaults like this now can I?

What should I do because when I pass NULL for categoryid it says 'it expects parameter @categoryid which was not supplied'.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-07-22 : 15:46:02
Could you post your relevant ADO.NET code to make this more clear?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2008-07-22 : 15:55:34
In your .NET code, how about passing DBNull.Value rather than the keyword NULL?

---------------------------
EmeraldCityDomains.com
Go to Top of Page
   

- Advertisement -