DAAB GetParameterValue不返回输出参数值 [英] DAAB GetParameterValue does not return output parameter value
本文介绍了DAAB GetParameterValue不返回输出参数值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个存储过程,recives的放慢参数为OUTPUT参数中。该存储过程并将其值设置。我有以下的code在C#应用程序。但我没有得到在应用程序中的值(输出的返回值为0)。什么是这里缺少的环节?
CREATEPROCEDURE [DBO] .aspInsertZip code
(
@ CountOfUnchangedZip code AS INT = 0输出
)
如
开始
SET NOCOUNT ON
SET @ CountOfUnchangedZip code = 13
结束
在应用程序中,code如下:
的DbCommand CMD = db.GetStoredProcCommand(aspInsertZip code);
cmd.CommandTimeout = 0;
db.AddOutParameter(CMDCountOfUnchangedZip code,DbType.String,1000);
执行情况......
INT TempUnchageZipCount = Convert.ToInt32(db.GetParameterValue(CMD,@ CountOfUnchangedZip code));
解决方案
添加到您的SP:
返回@ CountOfUnchangedZip code
否则,你可能在你的code执行命令后使用是这样的:
VAR TempUnchageZipCount =(int)的cmd.Parameters [0] .value的;
I have a stored procedure that recives as paramter as OUTPUT paramter. The store procedure sets its value. I have the following code in C# application. But I am not getting the value in application (the output is returned as zero). What is the missing link here?
CREATEPROCEDURE [dbo].aspInsertZipCode
(
@CountOfUnchangedZipCode AS INT=0 OUTPUT
)
AS
BEGIN
SET NOCOUNT ON
SET @CountOfUnchangedZipCode = 13
END
In the application, code is as follows
DbCommand cmd = db.GetStoredProcCommand("aspInsertZipCode");
cmd.CommandTimeout = 0;
db.AddOutParameter(cmd, "CountOfUnchangedZipCode", DbType.String, 1000);
The execution happens ...
int TempUnchageZipCount = Convert.ToInt32(db.GetParameterValue(cmd, "@CountOfUnchangedZipCode"));
解决方案
Add to your SP:
RETURN @CountOfUnchangedZipCode
Otherwise you could use something like this after executing the command in your code:
var TempUnchageZipCount = (int) cmd.Parameters[0].Value;
这篇关于DAAB GetParameterValue不返回输出参数值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文