Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using primary index
Message
De
01/12/1998 14:59:50
 
 
À
01/12/1998 13:48:29
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00162863
Message ID:
00162918
Vues:
17
Pascal ---

Here is your problem: The AddNew() method in TSBaseForm class does a simple APPEND BLANK to add new records to a table. This would cause all fields to be initialized blank --- which may cause a duplicate conflict if there are already records with a blank primary key field(s).

What I would suggest is to replace the APPEND BLANK statment in TSBaseForm.AddNew() with THISFORM.InsertNew(). In TSBaseForm, create a new Method with the name InsertNew.

In each Form based on TSBaseForm (or TSMainForm which is a subclass of TSBaseForm and inherits the new method), edit the AddNew method to do an INSERT INTO command which adds the new record and populates any key fields; ie:

INSERT INTO mytable (primarykey) VALUES (nKeyValue)

This will resolve the problem.

>Hi John, I`m using the add() function of the Tastrade application without any further validation.
>
>i asked if VFP has a problem because somebody told me to never use primary keys. So i was wondering if it was my code or the product.
>
>thanks
------------------------------------------------
John Koziol, ex-MVP, ex-MS, ex-FoxTeam. Just call me "X"
"When the going gets weird, the weird turn pro" - Hunter Thompson (Gonzo) RIP 2/19/05
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform