ExecuteNonQuery不扔在插入异常 [英] ExecuteNonQuery doesn't throw exception on insert
问题描述
我使用OracleCommand.ExecuteNonQuery嗨
()来插入到表中。一切工作正常,但偶尔记录未插入。
那么有没有可能的ExecuteNonQuery()不插入的记录,也没有抛出异常?
Hi I'm using OracleCommand.ExecuteNonQuery() to insert into a table. Everything works fine but occasionally records are not inserted. So is it possible that ExecuteNonQuery() doesn't insert the record and also doesn't throw an exception?
我不使用存储过程。
我不使用事务。
我登录()我也由的ExecuteNonQuery抛出的任何异常,但显然不会抛出异常......
不可以检查的ExecuteNonQuery的返回值()。但是,它可能的ExecuteNonQuery如果插入成功?
I'm not using stored procedures. I'm not using a transaction. I am logging any exception that is thrown by ExecuteNonQuery() but apparently no exception is thrown... I am also not checking the return value of ExecuteNonQuery(). But is it possible that ExecuteNonQuery returns another value than 1 if the insert is successful?
推荐答案
它不应该返回大于1的其他值。的ExecuteNonQuery返回一个整数,指示受影响的行数。如果没有行被插入,0应返回。当它无法执行查询应该抛出的异常。 E.x:连接被关闭,该表不存在,等等。
It shouldn't. ExecuteNonQuery returns an integer indicating the number of rows affected. If no rows were inserted, 0 should be returned. It should thrown an exception when it fails to execute the query. E.x.: the connection is closed, the table doesn't exist, etc.
这篇关于ExecuteNonQuery不扔在插入异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!