dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: ODBC MICROSOFT ACCESS DRIVER ERROR

Hybrid View

  1. #1
    Join Date
    Aug 2004
    Posts
    43,023

    ODBC MICROSOFT ACCESS DRIVER ERROR

    [Originally posted by Avi]

    How do I trap and change the description of errors if they happen like these:

    Run-time error '-2147217900 (80040e14)':
    [MICROSOFT] [ODBC MICROSOFT ACCESS DRIVER]
    The changes you requested to the table were not successful because they would 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.

    Run-time error '-2147217900 (80040e14)':
    [MICROSOFT] [ODBC MICROSOFT ACCESS DRIVER]
    You cannot add or change a record because a related record is required in table
    'Tbl_ServiceDetails'





  2. #2
    Join Date
    Aug 2004
    Posts
    43,023

    Re:ODBC MICROSOFT ACCESS DRIVER ERROR

    [Originally posted by Larry Asher]

    That is a real pain in the butt! I really like the error handling in DAO much better, it was much more explicit. But, I guess that is the price we pay for having such a dynamic data access object.

    If I understand you correctly what you are getting at is the same error number and two different error messages. I think for the most part you have to predict what the user is doing and I guess in a broader sense the error messages are indicating the same thing, ther is no primary key. The difference in the error messages appears to be that one is being generated when a change is being made to a related table, the second message, and the first message is referring to the table that contains the primary key.

    I think you can use some more code in your program to determine what is is the user is actually doing and then if you want to elaborate on the error message you can.

    Also, I feel it is important to be able to know what the user is doing so that you can be better able to troubleshoot any problems that may arise.

    Hope this helps.

    Good luck.

  3. #3
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:ODBC MICROSOFT ACCESS DRIVER ERROR

    [Originally posted by Avi]

    Is there no way I can trap the error and change its descriprion? because all my MsgBox's are in Hebrew and I would like to keep it that way


  4. #4
    Join Date
    Aug 2004
    Posts
    43,023

    Re:ODBC MICROSOFT ACCESS DRIVER ERROR

    [Originally posted by Larry Asher]

    What you could do is the force the error or recreate the error. Then in your error handling code, I am assuming you are using error handling,
    start off with something like:

    Private Sub DataStuff() ' Maybe your is a function

    ' Place this code at the beginning of your˙ ˙ ˙ ˙ procedure
    On Error GoTo ErrorHandler

    ' Write your database code here

    ' If no errors occur
    Exit Sub ' Or if function Exit Function

    ErrorHandler:

    ' This is where you can trap your errors
    MsgBox Err.Number

    End Sub ' or Function

    This will allow your to identify the error number.
    Then modify the code to look for that number - it's a big one.

    Private Sub DataStuff() ' Maybe your is a function

    ' Place this code at the beginning of your˙ ˙ ˙ ˙ procedure
    On Error GoTo ErrorHandler

    ' Write your database code here

    ' If no errors occur
    Exit Sub ' Or if function Exit Function

    ErrorHandler:

    ' This is where you can trap your errors
    If Err.Number = -2147217900 Then
    ˙ ' No primary key was found
    ˙ ' This is where you can change the message
    ˙ ' Just display a message box
    ˙ MsgBox "No primary key - in Hebrew", _˙ ˙ ˙ ˙ vbExclamation, App.Title
    Else
    ˙ ' Handle all other errors
    ˙ MsgBox "Unexpected Error: " & Err.Number _
    & " " & Err.Description, vbExclamation, App.Title
    End If

    End Sub ' or Function


    If you have not been handling errors I would suggest that you start. Especially when working with a database. Handling errors can go along way to prevent your program from crashing. In some cases you can correct the error in your program without troubling the user.

    Errors can be handled in a many different ways. I would suggest spending some time reading up on error handling.

    Best of Luck.

  5. #5
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:ODBC MICROSOFT ACCESS DRIVER ERROR

    [Originally posted by Avi]

    i've decided to do some thing like this:

    private sub DataStuff()
    on error goto ErrorHandler

    'Here is where i've written my input check..everything i could think of by using isnumeric, isdate,len etc. '

    ErrorHandler:
    if (err) then
    ˙ ˙ msgbox "here i've written possible suggestions in hebrew what might be wrong and what the user should do in order to correct the error"
    exit sub
    end if
    i think it's good enough..
    thanks anyway





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