ExecuteNonQuery返回-1 [英] ExecuteNonQuery returns -1

查看:76
本文介绍了ExecuteNonQuery返回-1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个存储过程,它返回一个 string 值,我必须使用 ExecuteNonQuery 语句执行此SP。执行此操作时,我得到的返回值为-1。

I have a stored procedure and it returns a string value, and I have to execute this SP using ExecuteNonQuery statement. When I execute this, I get -1 as the return value.

我从未使用过 SET NOCOUNT ON 。如何获得返回值?我没有将返回值声明为 OUTPUT -仅 SELECT @VARIABLENAME 。如何使用 ExecuteNonQuery 获得值?

I never used SET NOCOUNT ON. How can I get the return value? I did not declare the return value as OUTPUT -- just SELECT @VARIABLENAME. How can I get the value using ExecuteNonQuery?

推荐答案

ExecuteNonQuery 用于执行查询仅返回受影响的行数(尽管可以填充输出参数)。 -1 表示没有行受到影响或您未设置任何计数。

ExecuteNonQuery is used to execute queries that return only the number of rows affected (though output parameters can be populated). -1 means that no rows were affected or you have set nocount on.

如果您使用其他API调用需要从存储过程中读取数据。

Use another an API call if you need to read data from the sproc.

这篇关于ExecuteNonQuery返回-1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆