ExecuteNonQuery return -1

Posted on 2008-11-08
Last Modified: 2012-05-05
From my vb net application I call a stored procedure in a Pervasive database. This is the st.proc.
CREATE PROCEDURE "spUpdateAllineaPos18" (in :AllineaPos18 utinyint,
in :Descrizione varchar(50));

      UPDATE AnaAllineaPos18
      SET Descrizione = :Descrizione
      WHERE AllineaPos18 = :AllineaPos18;

To call it I use a PSqlCommand. What is strange is that if I call ExecuteNonQuery the method always return -1 but the stored was executed exactly. Why?
Question by:fantamen
    LVL 142

    Accepted Solution

    that is normal, because that procedure does not return any records, ie it does not run a UPDATE, INSERT, DELETE statement directly.
    calling a stored procedure will hence return -1. it's not 100% clear in the docs, though:

    if you want the number of rows affected, you have to "return" that in a output parameter, for example.

    Author Comment

    Dear angellll I've modified my stored procedure:
    CREATE PROCEDURE "spUpdateAllineaPos18" (in :AllineaPos18 utinyint,
    in :Descrizione varchar(50), out :RecUpd integer);

          UPDATE AnaAllineaPos18
          SET Descrizione = :Descrizione
          WHERE AllineaPos18 = :AllineaPos18;
          SET :RecUpd = @@ROWCOUNT;

    In vb code I read the output parameter RecUpd and it look to work correctly. What do you think?
    LVL 142

    Expert Comment

    by:Guy Hengel [angelIII / a3]
    >SET :RecUpd = @@ROWCOUNT;
    yes, that is exactly the most performant method, AFAIK.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Introduction This article makes the case for using two modules in your VBA/VB6 applications to provide both case-sensitive and case-insensitive text comparison operations.  Recently, I solved an EE question using the LIKE function.  In order for th…
    If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now