ExecuteNonQuery() returns -1 in Update when records are updated

后端 未结 2 1151
执笔经年
执笔经年 2021-01-06 01:25

I\'ve verified that my method/Oracle procedure is working correctly, but in my C# I always get -1 returned from ExecuteNonQuery(). Consequently, the below bool is always fa

相关标签:
2条回答
  • 2021-01-06 01:58

    Try explicitly returning SQL%ROWCOUNT.

    According to MSDN, DbCommand..ExecuteNonQuery will always return -1 for stored procedure calls:

    For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. For all other types of statements, the return value is -1.

    If I remember correctly from my days of using lots of stored procs, I believe you would need to use an output argument to return stuff like the number of updated rows.

    0 讨论(0)
  • 2021-01-06 02:04

    I'm not an Oracle guy, but apparently there's a command:

    set feedback off
    

    which prevents it from returning the count of records affected. Is this line in the stored procedure? Or have you tried 'set feedback on'? Functionally I think this is just the reverse of SQL Server's SET NOCOUNT ON/OFF command.

    0 讨论(0)
提交回复
热议问题