ExecuteNonQuery()返回-1 [英] ExecuteNonQuery() returning -1

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

问题描述

你好,

我正在使用存储过程在sql中插入数据,其工作正常,但cmd.executenonquery返回-1.
谁能告诉我它返回-1还是我的代码有问题?

在此先感谢您.

Hello,

I am inserting data in sql using store procedure, its working fine but cmd.executenonquery returning -1 .
Can any one plz tell me that either it return -1 or there is any problem with my code?

Thanks in advance.

推荐答案

您是否正在使用内联查询.检查此链接: http://msdn.microsoft.com/en-us/library /59x02y99(vs.71).aspx
Are you using inline queries. Check this link: http://msdn.microsoft.com/en-us/library/59x02y99(vs.71).aspx


您是否已在
如果不是,则可能是代码问题.
Have you got a trigger running on your table[^]?

"For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. When a trigger exists on a table being inserted or updated, the return value includes the number of rows affected by both the insert or update operation and the number of rows affected by the trigger or triggers. For all other types of statements, the return value is -1. If a rollback occurs, the return value is also -1."

If not, you might have an issue with the code.


在这里看看: ^ ]

它说:
返回值:一个Int32值,它指定UPDATE,INSERT和DELETE语句受Transact-SQL命令影响的总行数.对于所有其他类型的语句,返回值为-1.

现在,这取决于您在做什么.尽管您说的是插入,但是看起来好像不是以正确的预期方式进行的.
Have a look here: ServerConnection.ExecuteNonQuery Method [^]

It says:
Return Value: An Int32 value that specifies the total number of rows affected by the Transact-SQL command for UPDATE, INSERT, and DELETE statements. For all other types of statements, the return value is -1.

Now, it depends on what are you doing. Though you say Inserting, but looks like not in a proper expected way.


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

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