Click here to Skip to main content
16,015,218 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
Hi All,

In my stored procedure I have declared some parameters as NULL values(Optional Parameters).
In my C#.NET code I didn't use the parameters to pass values to Stored Procedure's NULL

Parameters. So I am getting Exception.

I don't want to pass parameters from my code.Because I have declared 30 parameters in my

Stored Procedure as NULL values.

Is there any other way to execute Stored Procedure from Front End without passing values to
Optional Parameters in SQL stored procedure?

Regards,
NSJ
Posted

Hi,

Please create procedure like following

CREATE PROC usp_proc1
@id bigint=0,
@name varchar(24)='',
@rollno int=0
AS
Insert into tablename values(@id,@name,@rollno)


When you declare input parameter assign them with default value then from front end you not need to pass any value.

Hope it helps :)
 
Share this answer
 
Don't include the optional parameters in your stored procedure's required parameter list and you don't need to pass it.

Or did I get your question wrong?
 
Share this answer
 

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