ibrobar
asked on
Auto increment / key violation
Hi
My problem is that when I am deleting a record from a table based on an Auto Increment key it's giving me a KEY Violation error message
How can I solve this problem should I change the key ?
By the way I am using this table and it's query to populate a listview i am using in my program
regards
My problem is that when I am deleting a record from a table based on an Auto Increment key it's giving me a KEY Violation error message
How can I solve this problem should I change the key ?
By the way I am using this table and it's query to populate a listview i am using in my program
regards
does your table have any "triggers" or "events" that may be firing when you do the delete?
I'd start searching there first
I'd start searching there first
Try this scenario
1. Close the table/query.
2. delete the record.
3. reopen and populate your data
1. Close the table/query.
2. delete the record.
3. reopen and populate your data
The problem might be with indices. So, if the indices are corrupted then you can see such type of problem.
Reindex and try.
Reindex and try.
Yeah, it is bug with Paradox. you need Pdxrbld - Paradox tables check/repair utility.
You can find it http://www.torry.net/authorsmore.php?id=1728
You can find it http://www.torry.net/authorsmore.php?id=1728
ASKER
Dear All I am using Paradox table and Delphi version 4
I am filling a listview from this table I mentioned earlier and the key is Auto increment so when I am deleteing an item from the listview i am deleting it from the table assigned to. so when i am doing the delete it's giving me this error message Key violation . i think i cann't delete from an autoincement key table cause it will make gaps in the records
so any solution
regards
I am filling a listview from this table I mentioned earlier and the key is Auto increment so when I am deleteing an item from the listview i am deleting it from the table assigned to. so when i am doing the delete it's giving me this error message Key violation . i think i cann't delete from an autoincement key table cause it will make gaps in the records
so any solution
regards
You didn't get my point.
In paradox when you use AutoIncrement, it uses secondary index to maintain autoincrement. Now for some reason it fails to track the autoincrement and raises this error. The solution is NOT to use the autoincrement and design your own increment routine for this purpose.
See http://www.dbforums.com/archive/index.php/t-386182.html
In paradox when you use AutoIncrement, it uses secondary index to maintain autoincrement. Now for some reason it fails to track the autoincrement and raises this error. The solution is NOT to use the autoincrement and design your own increment routine for this purpose.
See http://www.dbforums.com/archive/index.php/t-386182.html
Have you edited the table's data at all before trying to delete it??
Try doing a "Table1.Cancel;" before the "Table.Delete;"
Try doing a "Table1.Cancel;" before the "Table.Delete;"
usual a delete will not cause a keyviolation,
except there is a constraint to a childtable
what is your exact errormessage?
meikl ;-)
except there is a constraint to a childtable
what is your exact errormessage?
meikl ;-)
>In paradox when you use AutoIncrement, it uses secondary index to maintain autoincrement.
is of course nonsens, there is no secondary index until someone explicite define/create it
(the autoinc-value is maintained in the header part of the table-file)
meikl ;-)
is of course nonsens, there is no secondary index until someone explicite define/create it
(the autoinc-value is maintained in the header part of the table-file)
meikl ;-)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>>I am filling a listview from this table I mentioned earlier and the key is Auto increment so when I am deleteing an item from the listview i am deleting it from the table assigned to.
Try to delete a record with out filling the list view(is it dbcomponent?)
What is happening?
Post your code
sun4sunday
Try to delete a record with out filling the list view(is it dbcomponent?)
What is happening?
Post your code
sun4sunday
What type of database?
what version of delphi.
Snippet of code that gives the code violation or area of code that is used to delete the record.
Scay7