【发布时间】:2010-11-02 08:49:00
【问题描述】:
我有以下非常基本的存储过程:
创建过程 [dbo].[GetNumberToProcess]
作为
返回 999
然后我有一些代码使用企业库运行并获取返回值:
Dim cmd As DbCommand
Dim ResultValue as String
Dim lDBCommand as String = "dbo.GetNumberToProcess"
Dim actionDB As Sql.SqlDatabase = New Sql.SqlDatabase(lConnectionString)
cmd = actionDB.GetSqlStringCommand(lDBCommand)
Dim SQLreturnValue As New SqlParameter("RETURN_VALUE", DbType.Int32)
SQLreturnValue.Direction = ParameterDirection.ReturnValue
cmd.Parameters.Add(SQLreturnValue)
' Execute the command and put the result into the ResultValue for later processing
actionDB.ExecuteNonQuery(cmd).ToString()
ResultValue = cmd.Parameters("RETURN_VALUE").Value.ToString
问题是,当我应该得到“999”时,我得到的结果值是“0”(存储过程被非常缩减,这样我就可以深入了解它为什么不起作用)。
根据我在网上看到的多个示例,这应该可行。
有人对为什么不这样做有任何建议吗?
【问题讨论】:
标签: sql stored-procedures return-value