ExecuteNonQuery return value


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: ExecuteNonQuery return value

  1. #1
    Steve Guest

    ExecuteNonQuery return value


    Dear All,
    How can I get the actual error code or message when ExecuteNonQuery is executed?
    We can check the status of the ExecuteNonQuery by the return value indicating
    number of row affected. If an error occurred, the return value is 0, but
    what is the actual error that causing it? Thanks in advance.

    Regards,
    Steve.

  2. #2
    Michael Gautier Guest

    Re: ExecuteNonQuery return value

    You should of gotten an exception if there was an error.

    if you have

    try{
    DataThing.ExecuteNonQuery();
    }
    catch{
    }

    you won't see it versus

    try{
    DataThing.ExecuteNonQuery();
    }
    catch{System.Data.SQLorOracleClient.SQLorOracleException Exception) {
    MessageBox.Show(Exception.Message.ToString());
    }


    SqlException has a number property you can check.

    "Steve" <vb.@127.0.0.1> wrote in message
    news:3e8129d0$1@tnews.web.devx.com...
    >
    > Dear All,
    > How can I get the actual error code or message when ExecuteNonQuery is

    executed?
    > We can check the status of the ExecuteNonQuery by the return value

    indicating
    > number of row affected. If an error occurred, the return value is 0, but
    > what is the actual error that causing it? Thanks in advance.
    >
    > Regards,
    > Steve.




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center