Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Uniqueness of index violation
Message
 
À
10/09/1997 10:27:11
Elyse Pomerantz
Dynamic Data Concepts, Inc.
Brooklyn, New York, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00049180
Message ID:
00049316
Vues:
56
>>>I have a problem that I can't for the life of me figure out. I have a form that is used to register people for classes. There are (among other things) five text boxes that define the class (i.e.-year, class, section, term, period). I enter values for these five fields (all bound to the same table) and then call another form (seems to be irrelevant which one). The second form has nothing in its DataEnvironment. After closing the second form, I retype the value in the Year field (re-entering the same value) and call the second form again. When closing the second form, the program crashes on the following line of code in the Activate of the first form:
>>>
>>>go iif(this.nRecNum>0,this.nRecNum,reccount("classfile")) in classfile
>>>
>>>The error message is "Uniqueness of index STUDENT is violated."
>>>
>>>Relevant info:
>>>1) this.nRecNum= -1 (for new record)
>>>2) The Primary index STUDENT is on AccountNum+Year+Term+Sequence# (for !deleted())
>>> (The seq# is not generated until record is saved. At this point it is blank.)
>>>3) The BufferMode is set to 5 - Optimistic Table
>>>4) No tablerevert or tableupdate is issued yet.
>>>5) There are no other records in the file for this Account Number.
>>>6) There is only one appended new record.
>>>
>>>Why am I getting this error when there is really no violation?
>>>
>>>Any help would be greatly appreciated.
>>>
>>>Elyse
>>
>>You must assign a unique value to STUDENT before leaving that record. If you are not using private datasessions, then the activate event of the second form is attempting to move the record pointer in the cursor in the first, before you have asigned the unique value. Most likely you will want to use privatedatasessions in this situation. HTH
>>
>>Erik
>
>But the key is unique! The Account # is part of the key and there are no other records for this Account #.
>
>Elyse

if you add (generate) the assigned numbers when you add/create the record you shouldn't have this problem. remember that if a deleted record has the same key, this error will occur. generating these numbers at record creation will (if your generator code is good) prevent duplicate records.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform