如何在不将值传递给SQL存储过程中的可选参数(我将参数声明为NULL值)的情况下从前端执行存储过程? [英] How to execute Stored Procedure from Front End without passing values to Optional Parameters(I declared parameters as NULL values) in SQL stored procedure?

查看:172
本文介绍了如何在不将值传递给SQL存储过程中的可选参数(我将参数声明为NULL值)的情况下从前端执行存储过程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

在我的存储过程中,我已将某些参数声明为NULL值(可选参数).
在我的C#.NET代码中,我没有使用参数将值传递给存储过程的NULL

参数.所以我得到了异常.

我不想从代码中传递参数.因为我在
中声明了30个参数
存储过程为NULL值.

是否有其他方法可以从前端执行存储过程而无需将值传递给
SQL存储过程中的可选参数?

问候,
NSJ

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

推荐答案



请按照以下步骤创建程序

创建PROC usp_proc1
@id bigint = 0,
@name varchar(24)='''',
@rollno int = 0
AS
插入表名值(@ id,@ name,@ rollno)


声明输入参数时,请为它们分配默认值,然后从前端开始就不需要传递任何值.

希望对您有所帮助:)
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 :)


不要在存储过程的必需参数列表中包含可选参数,并且您不需要传递它.

还是我弄错了您的问题?
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?


这篇关于如何在不将值传递给SQL存储过程中的可选参数(我将参数声明为NULL值)的情况下从前端执行存储过程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆