Click here to Skip to main content
15,886,137 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I need to pass to optional parameter to Stored Procedure using following method;
C#
Microsoft.Practices.EnterpriseLibrary.Data.Database.LoadDataSet(string storedProcedureName, DataSet dataSet, string[] tableNames, params Object[] parameterValues)
But the method raises an exception, if the optional parameter is not provided.
I've tried the SP in database, without passing optional parameter which it works fine.

Do we have any way to do this?

Thanks In Advance
Avinash S. Godse
Posted
Updated 30-Mar-12 1:01am
v4
Comments
ZurdoDev 29-Mar-12 11:26am    
Are you sure the method is raising the exception and not the SQL SP? What does the SQL SP look like? The method takes an array of parameters so it may not care if you specify an optional parameter or not it may actually be the SQL that is causing the exception.
avigodse 29-Mar-12 11:35am    
Yes, its method that is raising exception, cause I've tried the SP in database, without passing optional parameter which it works fine.
Dean Oliver 29-Mar-12 17:02pm    
Whats the exception being thrown?
wizardzz 29-Mar-12 17:37pm    
What's the exception and what does your code look like when calling it?
avigodse 30-Mar-12 11:59am    
Hi,
Method gives parameter not provided exception, I think no need to paste actual exception message.
Actual code is very common.

1 solution

you have to declare parameter as optional in S.P and set it to null or any explicit value..
i.e

SQL
Create Procedure myProcedure
    @attrib1 int,
    @attribOptional varchar(10) = null
as
   BEGIN
       --Body of procedure
   END
 
Share this answer
 
v2
Comments
avigodse 30-Mar-12 11:49am    
Thank you Zaib, but this is not the answer, I am looking for.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900