Results 1 to 8 of 8

Thread: [2005] ADO.Net Error Handling

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2003
    Posts
    758

    [2005] ADO.Net Error Handling

    I have a SQL Server SP that takes 3 parameters. My InsertCommand sets 2 of the 3 parameters and the 3rd one gets "default". When I call SqlDataAdapter.Update(), I don't get an error generated in my code, but the insert fails. If I run the exact same line in Query Analyzer, it returns "Procedure 'spName' expects parameter '@Param3', which was not supplied.

    How can I test for this error situation? My application should not just continue to process data and make the user think it worked, when it actually did not.
    My.Settings.Signature = String.Empty

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: [2005] ADO.Net Error Handling

    Try
    -- put your .Update here
    Catch sqlEx as SQLException
    messagebox.show sqlex.tostring
    Catch ex as SystemException
    messagebox.show ex.tostring
    Finally
    --optional stuff here
    End Try

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    May 2003
    Posts
    758

    Re: [2005] ADO.Net Error Handling

    I already have that in place. Nothing is caught there.
    My.Settings.Signature = String.Empty

  4. #4
    Fanatic Member
    Join Date
    Aug 2006
    Location
    In my head
    Posts
    913

    Re: [2005] ADO.Net Error Handling

    I have had this happen before as well. I had to actually adjust the stored procedure to handle a return code and a return message. Then in the stored procedure I had it test each parameter and return a 1 if it failed and a 0 (at the end) if it succeeded. Actually I have that on all my stored procedures now. It has not added any measurable amount of processor time and some of my procedures take up to 30 parameters

    The other work around is that set the parameter = null in the stored procedure. Then just add parameter to your command setup in your program but don't assign it a value or assign it a default value.

    Good Luck,

    D
    Platforms of choice: Visual Studio 2005/2008 Professional : Visual Studio 2010 Enterprise : PHP - Notepad++/WAMP

    Please Rate If I helped you.
    Please remember to mark threads as closed if your issue has been resolved.

    Reserved Words in Access | Connection Strings

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: [2005] ADO.Net Error Handling

    If it's not catching it, then there's something else wrong... because I *Know* it does catch.... what does your code look like?

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    May 2003
    Posts
    758

    Re: [2005] ADO.Net Error Handling

    If there is an error inside of the procedure (a field is in a select list that doesn't exist in the table), it will catch that. It will not catch the "Procedure 'spName' expects parameter '@Param3', which was not supplied".
    My.Settings.Signature = String.Empty

  7. #7
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: [2005] ADO.Net Error Handling

    Then by all means.... you go right ahead.... clearly you know what you are doing.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    May 2003
    Posts
    758

    Re: [2005] ADO.Net Error Handling

    What's with the attitude? I came here asking for help, not an attitude.
    My.Settings.Signature = String.Empty

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width