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

后端 未结 2 1173
执笔经年
执笔经年 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.

提交回复
热议问题