Subject Re: [firebird-support] Firebird ADO.NET: ExecuteNonQuery Returns -1 On Successful Insert
Author Helen Borrie
Steve Naidamast wrote:

> I am using the Firebird 2.5 Embedded Edition with the Firebird
> ADO.NET provider version 5.5 or 5.7. I am not sure which, since it
> has been so long since I set up the references for my project and
> the assembly being used is not taken from the actual provider
> library that has all the files in it..

> In any event, during a test of my current application development I
> successfully inserted a record into a table using a Firebird stored
> procedure with the ADO.NET ExecuteNonQuery method, which should
> return a "records affected" count of "1".

> Instead, I am finding that the returned "records affected" count is "-1".

You posted this to the database support list. You want to post it to
the firebird-net-provider list (google group, not sourceforge) so that
someone who knows can tell you what the expectations are in ADO for
RecordsAffected by an insert from a PSQL module.

> I have never seen this before with all the other database engines I
> have worked with over the years. Nonetheless, I believe I have seen
> this issue raised with Firebird ADO.NET before but some time ago.

> Does anyone have any idea as to what is causing this?

Well, I don't do ADO but to me, logically, a record can't be affected
if it didn't exist before the DML operation, so only reows affectd by
update or delete operations would be counted, if any such count were
available. I think that's how it works in MSSQL.
The context variable ROW_COUNT is available in PSQL for you to do
something with *inside* the module, e.g., to pass it to an output
parameter. It does give you a row count for each DML operation as it
completes. Of course, this means its value changes in a module that
has multiple DML statements.

I don't know of any other way to get row counts from executing a PSQL
module. Maybe the Firebird ADO.NET provider is able to wrap such
output from an ExecuteNonQuery into this RowsAffected value....wild
guess here. Ask on the right forum.