ADO 2.1 / Error -2147467259


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: ADO 2.1 / Error -2147467259

  1. #1
    EHi Guest

    ADO 2.1 / Error -2147467259

    I use the code below to update Access file with data from remote system.
    Besides the primary keys there are some fields with ‘no duplicates’ index.
    When the update file contains a conflicting value, ADO raises the
    rror –2147467259 “…duplicate values in the index…”, routine in writeErr:
    changes the value and returns to the loop. Now the SQL clause is executed
    normally. Problem is that this happens only ones. Next conflicting value
    stops the program without any error control. What’s the problem?

    Thanks in advance for your help.

    <EHi>

    ----Code clip ---------------------------
    On Error GoTo writeErr
    Set cnnADO = New ADODB.Connection
    cnnADO.Provider = "Microsoft.Jet.OLEDB.4.0"
    cnnADO.Open DBName, "Admin", ""
    cnnADO.BeginTrans
    For i = 0 To UBound(aSQLs)
    tryAgain:
    cnnADO.Execute aSQLs(i), lAffected, adCmdText + adExecuteNoRecords
    Next i
    cnnADO.CommitTrans
    cnnADO.Close
    ...
    Exit Function

    writeErr:
    'aSQLs(i) is modified so that there is no longer any conflict with the
    existeng value
    ...
    cnnADO.Errors.Clear
    Err.Clear
    GoTo tryAgain
    -------------------------------------------------






  2. #2
    Dean Guest

    Re: ADO 2.1 / Error -2147467259


    Use Resume TryAgain instead of Goto TryAgain.
    Any errors in an error handler will cause the app to terminate.
    ~DL

    "EHi" <ehi@cips.fi> wrote:
    >I use the code below to update Access file with data from remote system.
    >Besides the primary keys there are some fields with ‘no duplicates’ index.
    >When the update file contains a conflicting value, ADO raises the
    >rror –2147467259 “…duplicate values in the index…”, routine in writeErr:
    >changes the value and returns to the loop. Now the SQL clause is executed
    >normally. Problem is that this happens only ones. Next conflicting value
    >stops the program without any error control. What’s the problem?
    >
    >Thanks in advance for your help.
    >
    ><EHi>
    >
    >----Code clip ---------------------------
    > On Error GoTo writeErr
    > Set cnnADO = New ADODB.Connection
    > cnnADO.Provider = "Microsoft.Jet.OLEDB.4.0"
    > cnnADO.Open DBName, "Admin", ""
    > cnnADO.BeginTrans
    > For i = 0 To UBound(aSQLs)
    >tryAgain:
    > cnnADO.Execute aSQLs(i), lAffected, adCmdText + adExecuteNoRecords
    > Next i
    > cnnADO.CommitTrans
    > cnnADO.Close
    > ...
    > Exit Function
    >
    >writeErr:
    > 'aSQLs(i) is modified so that there is no longer any conflict with the
    >existeng value
    > ...
    > cnnADO.Errors.Clear
    > Err.Clear
    > GoTo tryAgain
    >-------------------------------------------------
    >
    >
    >
    >
    >



  3. #3
    EHi Guest

    Re: ADO 2.1 / Error -2147467259

    Thanks, it is so simple when you know it.

    <EHi>

    Dean wrote in message <38d8104e$1@news.devx.com>...
    >
    >Use Resume TryAgain instead of Goto TryAgain.
    >Any errors in an error handler will cause the app to terminate.
    >~DL





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