Paradox Key Violation - changing a keyed field 
Author Message
 Paradox Key Violation - changing a keyed field

I have a Delphi app that needs to be able to change a key field. When
I use the DBEdit component I get a "key violation" when the value is
changed and I try to Post.

The table is a driver for every other table in the app so using the
"+" increment field is not practical.

Is there a solution to this problem?



Wed, 18 Jun 1902 08:00:00 GMT
 Paradox Key Violation - changing a keyed field

You shouldn't be getting a key violation unless you are trying to enter a
value that already exists in the table. You didn't mention when you get the
key violation (i.e., what actions you are doing that lead up to it). Just
"using" the DBEdit does not cause a key violation.
--
Mark Bratcher



Quote:
> I have a Delphi app that needs to be able to change a key field. When
> I use the DBEdit component I get a "key violation" when the value is
> changed and I try to Post.

> The table is a driver for every other table in the app so using the
> "+" increment field is not practical.

> Is there a solution to this problem?



Wed, 18 Jun 1902 08:00:00 GMT
 Paradox Key Violation - changing a keyed field

You shouldn't be getting a key violation unless you are trying to enter a
value that already exists in the table. You didn't mention when you get the
key violation (i.e., what actions you are doing that lead up to it). Just
"using" the DBEdit does not cause a key violation.
--
Mark Bratcher



Quote:
> I have a Delphi app that needs to be able to change a key field. When
> I use the DBEdit component I get a "key violation" when the value is
> changed and I try to Post.

> The table is a driver for every other table in the app so using the
> "+" increment field is not practical.

> Is there a solution to this problem?



Wed, 18 Jun 1902 08:00:00 GMT
 Paradox Key Violation - changing a keyed field



Quote:
>I have a Delphi app that needs to be able to change a key field. When
>I use the DBEdit component I get a "key violation" when the value is
>changed and I try to Post.

What version of Paradox tables?

Any referential integrity set?  If so, set it to Cascade.  Paradox
referential integrity has two modes, one that cascades the key-changes
down to child tables, and one that just prevents you from changing the
parent key, if it would create orphan child records.

If no referential integrity, there is nothing special your code needs
to do,  You will get the Key violation exception if you change the key
to a value already in the table.  That is the only reason you should
get the exception.  To "catch" the key violation error and display
your own error message, use a Try/Except around the POST.

Chuck Gadd
Director of Software Development, {*filter*} FX Communications.

Remove the -NOSPAM from my email address to send me e-mail.
*** I boycott businesses that send me unsolicited email adverti{*filter*}ts ***



Wed, 18 Jun 1902 08:00:00 GMT
 
 [ 4 post ] 

 Relevant Pages 

1. Reordering of key fields leads to key violations (Pdox 5.0)

2. Reordering of key fields leads to key violations (Pdox 5.0)

3. Paradox Autoincrement Fields Cause Key Violation -- Help!

4. Preventing Key Violation for duplicate keys

5. Violation of PRIMARY KEY constraint Cannot insert duplicate key in object

6. INSERT INTO TABLE KEYED ONLY ON IDENTITY COLUMN RESULTS IN KEY VIOLATION (6.5)

7. Paradox for Windows: Key Violation HELLLPP!

8. Q:Paradox Key Violations

9. Key Violation error with Paradox

10. V2 - Syntax to capture key violation on Paradox

11. Key Violations Not Returned by BDE / Paradox in Delphi 2


 
Powered by phpBB® Forum Software