Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
MAJOR question...
Message
De
25/01/2001 11:18:36
Cindy Winegarden
Duke University Medical Center
Durham, Caroline du Nord, États-Unis
 
 
À
25/01/2001 10:47:46
Chuck Tripi
University of Wisconsin - Milwaukee
Milwaukee, Wisconsin, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00468472
Message ID:
00468501
Vues:
10
Chuck,

In order to make this work you need to have your tables be part of a .DBC and have your INDEXES be PRIMARY or CANDIDATE. If so, FoxPro will do a lot of this for you and you won't have to code it!

The best way to use a primary key is to have a routine that generates it, like the NextID routine in TasTrade. This is a stored procedure that looks in a table, gets the next number, adds one and puts it back for the next use. There are table locking issues so be sure to check out the code, or look for Craig Berntson's very similar routine. Call the Stored Proc as a default value.

The user shoud really NEVER input the primary key. This field should have a PRIMARY index.

If the user is inputting a value which should be unique, like a SSN, and you want to warn the user if the value already exists you can either designate the index as CANDIDATE, or call a routine (stored procedure) which checks for the existence of this value and warns the user if it's already there. But the routine can never be foolproof because two users can add it at the same time. The CANDIDATE index works the same as the PRIMARY index. It won't let you input a duplicate value.

Look at Chapters 2 and 7 in the Programmer's Guide, and Chapter 4 in Effective Techniques (Booth and Sawyer), if you have it.

Hope this helps, post back with the parts you don't understand.


>VFP 6.0
>
>I have come to the point where I may be confused with how to program with Primary key, multi-users, (maybe) OOP, etc... I have MS VFP 6.0 Programmer's Guide and have read some other books, so I am not interested in buying a new book. If you could help me find it in MS (VFP) online Help article (or in my MS Programmer's Guide book) where I can read about how to best use uniquely the ID's (which I thought the Primary key was supposed to do that, but appearly not). I need to study (and program the coding) how to work with when allowing the user to input the ID, then check if this ID exist (via, if yes-> error message, if no-> enable the rest of the fields). But that's not done yet, I need to somehow "double-check" if another user in multi-network is using the same ID (highly unlikely, but still) so I can program to inform (either or both or whatever) that there is a possibly of duplicating ID. Maybe the only way is to catch this is when one of them saved the record, then the "next/last"
>user will be prompted with the error message?
>
>We did hired a consultant and this person is pretty good, but keeps reading the help files all the time and asks me, "Wow, thats nice, how to do that", stuff like that... Furthermore, I have CodeMine 6.1 framework, it is somewhere behind me (don't have that much of understanding of VFP).
>
>Keep in mind that I am former FPW 2.6 and I do very well with that, so stepping into VFP 6.0 for a while was a challenge, but I don't want to give up. Also, (not your fault <g>) I need to do this in timely manner (I am in the middle of the project right now and I am just like a sitting duck).
>
>Thank you.
>
>Chuck
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform