【发布时间】:2010-08-30 02:21:44
【问题描述】:
我在访问下面存储过程中的输出时遇到问题
DbParameter DbParm = command.CreateParameter();
DbParm.Direction = ParameterDirection.Output;
DbParm.ParameterName = "@SomeValue";
DbParm.DbType = DbType.Int32;
DbParm.Value = null;
command.Parameters.Add(DbParm);
执行程序后
command.Parameters["@SomeValue"].Value;
它总是返回 Null,不过我可以访问第二个选择。这里是过程:
CREATE PROCEDURE SomeThing
@SomeValue int OUTPUT,
AS
SELECT @SomeValue=ID
FROM SomeTable
WHERE ID=10;
SELECT *
FROM SomeTable;
GO
【问题讨论】:
-
您能向我们展示更多您的 C# 代码吗?如何将参数添加到
command.Parameters集合中? -
可能是错字,所以我不会将其作为答案发布,但 C# 代码的类型为 int32,而 DB 代码的类型为 nvarchar。
-
我怀疑这是因为使用了 2 个选择..
-
select * from SomeTable where id = 10的结果是什么? -
@Andomar 5 列 id 当然不为空
标签: c# sql tsql stored-procedures