程序或功能 [英] Procedure or function

查看:81
本文介绍了程序或功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

过程或函数期望未提供参数的原因,为什么会出现,如果出现则如何解决

Procedure or function expects parameter that was not supplied why it arise and if arise how to resolve it

推荐答案

在存储过程或函数中,将参数设置为默认值价值.因此,如果您不提供它,则不会消除错误.

例如:-

in your store procedure or function give your parameter to default value. so when you don''t supplied it will not ariase error.

example:-

create procedure procName
 @QryType int=0




如果您正在执行存储过程或函数,则可能需要传递一些参数信息.如果您未通过SqlParameter ,则它将引发此类异常.

您尚未提供更多信息,但请参见下面的代码,这可能是您的问题.

Hi,

if you are executing your storedprocedure or function, it may required some parameter information to be passed. if you are not passing SqlParameter then it will throw such exception.

you have not given more information but please see below code, this may be your problem.

SqlConnection conn = null;
SqlDataReader rdr  = null;
conn = new SqlConnection("YourConnectionString");
conn.Open();

SqlCommand cmd  = new SqlCommand("StoredProcedureName", conn);
           
cmd.CommandType = CommandType.StoredProcedure;

/* As you can see if your comment below code and if you have CustomerID as parameter in your Stored procedure then it will gives you exception. */
//cmd.Parameters.Add(new SqlParameter("@CustomerID", custId));
rdr = cmd.ExecuteReader();



请参见上面的代码. (特别评论.)

谢谢
-Amit.



Please see above code. (Specially comment.)

Thanks
-Amit.


这篇关于程序或功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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