插入存储过程错误 [英] insert Stored procedure error

查看:92
本文介绍了插入存储过程错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



请有人查看此代码,请告诉我哪里出错了。我无法支付

识别。 rooror说EMRUPl_Client_Insert中的更新失败。



请帮助。下面是我的c#代码和存储过程,用于插入和更新。



谢谢

Hi all

Please can anyone check this code and please let me know where i am going wrong.i am not able
to identify. The rooror says update fails in EMRUPl_Client_Insert.

Please help. Below is my c# code and stored procedure for insert and update.

Thanks

推荐答案

删除下面的行代码并再次检查。



Remove below line of code and check again.

theCmd.Parameters.AddWithValue("@city", _city);
                       theCmd.Parameters.AddWithValue("@state", _state);
                       theCmd.Parameters.AddWithValue("@occupation", _occupation);
                       theCmd.Parameters.AddWithValue("@status", _status);
                       theCmd.Parameters.AddWithValue("@ethnoracial", _ethnoracial);
                       theCmd.Parameters.AddWithValue("@interpretter", _interpretter);
                       theCmd.Parameters.AddWithValue("@monthlyincome", _monthlyincome);
                       theCmd.Parameters.AddWithValue("@referralsource", _referralsource);
                       theCmd.Parameters.AddWithValue("@pricelevel", _pricelevel);
                       theCmd.Parameters.AddWithValue("@userlist1", _userlist1);
                       theCmd.Parameters.AddWithValue("@userlist3", _userlist3);
                       theCmd.Parameters.AddWithValue("@userlist4", _userlist4);
                       theCmd.Parameters.AddWithValue("@userlist5", _userlist5);
                       theCmd.Parameters.AddWithValue("@usertext11", _usertext11);
                       theCmd.Parameters.AddWithValue("@usertext12", _usertext12);
                       theCmd.Parameters.AddWithValue("@usertext13", _usertext13);
                       theCmd.Parameters.AddWithValue("@usertext14", _usertext14);
                       theCmd.Parameters.AddWithValue("@usertext15", _usertext15);
                       theCmd.Parameters.AddWithValue("@usertext16", _usertext16);
                       theCmd.Parameters.AddWithValue("@usertext17", _usertext17);
                       theCmd.Parameters.AddWithValue("@usertext18", _usertext18);
                       theCmd.Parameters.AddWithValue("@usertext19", _usertext19);
                       theCmd.Parameters.AddWithValue("@usertext20", _usertext20);







问题是您的程序需要13个参数,但是您要添加额外的23个或更多参数。



希望这可以解决你的问题




the problem is that your procedure takes 13 parameters but you are adding additional 23 or more parameters.

Hopes this should resovle your porblem


过程或函数IMS_NB_EMRUP_Client_Insert指定了太多的参数...

你得到这个错误就意味着数学你传给你存储过程的参数。



它也在你的代码中看到你的存储过程中只有13个参数然后你传递超过13个参数它必须是相同的。
Procedure or function IMS_NB_EMRUP_Client_Insert has too many arguments specified"...
you get this error it means math your parameter which you pass to you store procedure.

And it is also saw in your code in you store procedure there is only 13 parameter and you pass more then 13 parameter it must be same.






我在评论中已经提到过..

您的存储过程需要13个输入参数

(@ PointId bigint,@ emrClientId char(25),

@RegisteredOn datetime,@ LastUpdated datet ime,

@NewAcceptorDate datetime,

@CurrentMethod char(25),

@Dob datetime,@ DotType char(10),

@ PregnanciesDemo1 smallint,

@ ChildrenDemo2 smallint,

@ AbortionsDemo3 smallint,

@ EducationDemo4 smallint,

@Sex smallint,



但你传递的是36左右(参见你的theCmd.Parameters.AddWithValue语句)。这就是为什么它给予例外。只传递所需的参数和你的概率。将被解决。并确保这是概率。使用输入执行你的sp在sql server中..你将确定它的概率。



和你的问题但我的表有所有23个参数。 ..如果我的表有23个参数,它会有什么不同吗?

我想告诉你,你的插入程序只会将数据插入到你传递值的那些列中(但仅限于你没有传递值的其他列允许null)



如果你的要求是向所有列插入数据然后向你的SP添加参数,否则从你的中删除额外的参数代码。



评论额外的theCmd.Parameters.AddWithValue语句并运行你的代码..它应该解决你的问题。
Hi,

as i already mentioned in my comment..
your stored procedures take 13 input parameters
( @PointId bigint, @emrClientId char(25),
@RegisteredOn datetime, @LastUpdated datetime,
@NewAcceptorDate datetime,
@CurrentMethod char(25),
@Dob datetime, @DobType char(10),
@PregnanciesDemo1 smallint,
@ChildrenDemo2 smallint,
@AbortionsDemo3 smallint,
@EducationDemo4 smallint,
@Sex smallint,
)
but you are passing about 36 (see your "theCmd.Parameters.AddWithValue" statements) . thats why it is giving exception. Pass only the required parameters and your prob. will be solved. and to make sure that this is the prob. execute your sp in sql server with inputs.. and you will be sure that its the prob.

and about your question that " But my table has all 23 parameters ...will it make any difference if my table has 23 parametrs"
I would like to tell you that your insert procedure will only insert the data into those columns for which your are passing values (but only if other columns for which you are not passing values allow null)

if your requirement is to insert data to all columns then add parameters to your SP otherwise remove extra parameters from your code.

comment extra "theCmd.Parameters.AddWithValue" statements and run your code.. it should resolve your prob.


这篇关于插入存储过程错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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