Board index » delphi » Paradox Key Violation - changing a keyed field

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?

 

Re: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
mbra...@ix.netcom.com

Gary Davies <gdav...@pressenter.com> wrote in article
<5n98pg$89...@jair.pressenter.com>...

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?

Re: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
mbra...@ix.netcom.com

Gary Davies <gdav...@pressenter.com> wrote in article
<5n98pg$89...@jair.pressenter.com>...

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?

Re:Paradox Key Violation - changing a keyed field


On Fri, 06 Jun 1997 14:46:41 GMT, gdav...@pressenter.com (Gary Davies)
wrote:

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, {*word*104} FX Communications.
e-mail:cgadd-NOS...@{*word*104}-fx.com  http://www.{*word*104}-fx.com
Remove the -NOSPAM from my email address to send me e-mail.
*** I boycott businesses that send me unsolicited email adverti{*word*224}ts ***

Other Threads