Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How do you handle update collision?
Message
Information générale
Forum:
Visual Basic
Catégorie:
Bases de données DAO/RDO/ODBC/ADO
Divers
Thread ID:
00238025
Message ID:
00238063
Vues:
17
Thank you very much for your reply Éric.

I've set up my On Error routine, except that Err.Number = 0 when saving a record modified by another user.

Here's the scenario:
- Start the EXE (A)
- Start a second copy pf the EXE (B)
- In A, edit the record but don't save (the command Edit is called when the record is displayed)
- In B, go to the same record, do some changes and save it (everything work fine so far)
- In A, press the Save button (Update is called)

The On Error routine is called, but Err.Number = 0. Why?

Here is the code:
    On Error GoTo UpdateError
    rsContrats.Update
    On Error GoTo 0
UpdateResume:
    SetMode "C"
    RefreshFields
    Exit Sub

UpdateError:
    On Error GoTo 0
    
    Select Case Err.Number
    Case 3167   ' Record is deleted
        MsgBox "Le contrat a été effacé par un autre usager"
        Resume UpdateResume
    Case 3186, 3197   ' 3186 - Couldn't save, currently lock
                      ' 3197 - Data has changed
        MsgBox "Un autre usager a modifié ce contrat. Les modifications n'ont pas été sauvées"
        Move 0
        Resume UpdateResume
    Case Else

==> This is what is called and "Erreur # 0" is displayed

        MsgBox "Erreur # " & Str(Err.Number) & " " & Err.Description
        End
    End Select
BTW, I'm using Access 97.

TIA

>You are right. You have to handle error using the "On Error Goto Somewhere" statement.
>
>The most important errors you should check for are the following:
>3260: Couldn't update, currently lock (can occur on Edit). Should not be a concern on Optimistic locking.
>3186: Couldn't save, currently lock (can occur on Update).
>3197: Data has changed, operation stopped (can occur on Edit and Update).
>3167: Record is deleted (can occur on Edit and Update).
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform