我有以下几个很基本的存储过程:返回值从存储过程没有设置
CREATE PROCEDURE [DBO] [GetNumberToProcess]
AS
RETURN 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”(存储过程非常简单,以至于我可以深入了解为什么它不工作)时,我得到的所有ResultValue都是“0”。
根据我在网上看到的多个例子,这应该工作。
任何人有任何建议,为什么它不?
这有用,你知道为什么吗?我怀疑GetSQLStringCommand没有通过返回值。 – 2009-06-14 23:47:06