Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
BO.CreateParameter and null
Message
 
To
25/05/2010 14:21:21
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
01465928
Message ID:
01465955
Views:
39
Frank,

One thing you could do is just add a default value in your stored procedure that will be used in the occurence of no value being passed to the stored procedure. Then the stored procedure will still run even if you do not pass a paramter value for one that has a default

Here is an example:
CREATE PROCEDURE [dbo].[ClientSelectByDynamic]
	@ClientNumber int = 0, @ClientName char(20) = '   ', @PolicyNumber char(20) = '  '

AS ...
I have never passed null as a parameter, but you could very easily pass something else (like a blank) and do what you want based on this input.

HTH
>Hi,
>
>I am trying a new technique with stored procedures and I need to pass null values to them in order to make it work.
>
>However, now I am getting an error on this line of code (C#)
>
>
return this.GetEntity("ClientsSelectByDynamic",
>this.CreateParameter("@ClientNumber", clientNumber),
>this.CreateParameter("@ClientName", clientName),
>this.CreateParameter("@PolicyNumber", policyNumber));
>
>The error I get is:
>
>System.Data.SqlClient.SqlException was unhandled by user code
>Message="Procedure or function 'ClientsSelectByDynamic' expects parameter '@ClientName', which was not supplied."
>
>I am guessing CreateParameter does not handle null values. What can I do to get this to work?
>
>I am using VS2008 and MM.NET 3.6
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform