Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Trapping Primary Key Violation
Message
De
08/12/2005 19:17:22
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01076240
Message ID:
01076461
Vues:
22
>This should be really simple, but I'm looking for a good way to trap a violation of a primary key error.
>
>I have a form in which the user has access to the primary key. So when they add it, as long is it's unique the table will update correctly (using tableupdate(). But if they add or change it to a duplicate I get a "uniqueness of vendornum is violated" message. Which is great. All I want to do at this point is display my own error and return them to the field where they can correct the error.
>
>What's the best way to do this? Thanks!
>
>(I'm this is on a form with optimistic row buffering)

You can SEEK(), to see whether the value still exists. I have a UDF that does that, with three parameters: the table name, the index name, and the proposed primary key or candidate key value. The idea is to re-open the table.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform