开发者

stored procedure not executing ASP .NEt

开发者 https://www.devze.com 2023-03-24 15:48 出处:网络
I have a .net application which calls a stored procedure (SQL Server 2008). The call to the SP is failing with the error message

I have a .net application which calls a stored procedure (SQL Server 2008). The call to the SP is failing with the error message

"Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used开发者_如何学C as an expression."

but when I manually execute the SP from SQL Server 2008 client with the same parameters as above, I have no issues.

Can any one help in fixing this?

Due to security reasons I can't post my SP here.


if you stored procedure returns the value, and you want to get this value, you need to use SET NOCOUNT ON in first strings of procedure.

EDIT: sorry I didn't understand the questions. Answer is wrong.


Sounds like the problem described here.

You could have a trigger on a table that is being modified by the stored procedure, and which is coded to expect only a single record being modified.

Perhaps you have something like:

declare @XYZ int
select @XYZ = FieldA from inserted

If your update modifies more than one record, then this statement will fail with your error message.

There's no reason why running in SSMS will not fail compared to ASP.NET, unless the SP itself checks environmental values e.g. current user from suser_sname() function, and so may not make any changes because of those values, and hence not firing the trigger.

If you don't have triggers, look for examples of the sample query above, and double check that they could never return more than one value.

0

精彩评论

暂无评论...
验证码 换一张
取 消