Results 1 to 6 of 6

Thread: Ignoring ADO errors

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2003
    Posts
    56

    Ignoring ADO errors

    What can I do to avoid the program stopping with an ADO error? It does not seem to be "trappeable"

    Example:

    objComm.CommandText = "INSERT INTO CorpExtractType (CorpCode, ExtractTypeID) VALUES ('" & sCorpCode & "'," & CStr(iExtractTypeID) & ")"
    objComm.Execute()

    This may fail due to a duplicate key for example, but I don't want to check for each command to see if the record already exist as it would slow things down. I just want to ignore any errors, but it won't play

    Putting a try-catch arround it does not help as it bombs on the objcomm.Execute statement.

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Ignoring ADO errors

    VB Code:
    1. Try
    2. objComm.CommandText = "INSERT INTO CorpExtractType (CorpCode, ExtractTypeID) VALUES ('" & sCorpCode & "'," & CStr(iExtractTypeID) & ")"
    3. objComm.Execute()
    4. Catch ex As Exception
    5. MessageBox.Show(ex.Message)
    6. End Try

  3. #3

    Thread Starter
    Member
    Join Date
    Mar 2003
    Posts
    56

    Re: Ignoring ADO errors

    I have got a try - catch around it, but it bombs on the objcomm.execute statement, i.e. it does not get trapped.

  4. #4

    Thread Starter
    Member
    Join Date
    Mar 2003
    Posts
    56

    Re: Ignoring ADO errors

    This is the message I get first:
    >>
    A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in Harpo.exe

    Additional information: The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again.

    >>

    And after that, it goes to the "catch" part

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Ignoring ADO errors

    ComException? What exactly are you using in your project? What is objComm?

  6. #6

    Thread Starter
    Member
    Join Date
    Mar 2003
    Posts
    56

    Re: Ignoring ADO errors

    objComm = New ADODB.Command


    These are ado commands.

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