Board index » delphi » Access and key violation error - HELP DESPERATELY NEEDED

Access and key violation error - HELP DESPERATELY NEEDED

I am using Microsoft Access via ODBC.  I originally used the built-in
MSACCESS driver, however the non-threading limitation was not acceptable, so
I switched to the ODBC access.  One of the primary tables I use is a table
with an auto-incrementing primary key.  Whenever I edit a record in this
database, Access flags a "Key Violation" exception.  It appears that Delphi
tries to write another instance of the same record, and of course two cannot
have the same ID (primary key).  For instance, if I put the table into Edit
mode, edit some fields, then Post, I get this error.  If instead I do a Next
on the destination table, which apparently implicitly calls Post, it is
fine, and the data does properly get posted.

What is happening here?  This is driving me absolutely insane, and I'm
wasting way too much time screwing around with database difficulties.  I can
handle the hack-around solution, however I've just tried using a TDBGrid,
and once again the dreaded Key Violation has appeared.  I have tried several
modifications with the BDE configuration, and the ODBC configuration, and
none has been successful.

Any help on this would be greatly appreciated.   PLEASE duplicate the
message to my email address in case it disappears in the newsgroup.

Thanks,
dfor...@execulink.com

 

Re:Access and key violation error - HELP DESPERATELY NEEDED


This may be similar to the problem I was having with record updates. Try
changing the ttable or tquery's update mode to whereKeyOnly.

Juan

Quote
Dennis Forbes wrote in message <6a0f2i$i2...@forums.borland.com>...
>I am using Microsoft Access via ODBC.  I originally used the built-in
>MSACCESS driver, however the non-threading limitation was not acceptable,
so
>I switched to the ODBC access.  One of the primary tables I use is a table
>with an auto-incrementing primary key.  Whenever I edit a record in this
>database, Access flags a "Key Violation" exception.  It appears that Delphi
>tries to write another instance of the same record, and of course two
cannot
>have the same ID (primary key).  For instance, if I put the table into Edit
>mode, edit some fields, then Post, I get this error.  If instead I do a
Next
>on the destination table, which apparently implicitly calls Post, it is
>fine, and the data does properly get posted.

>What is happening here?  This is driving me absolutely insane, and I'm
>wasting way too much time screwing around with database difficulties.  I
can
>handle the hack-around solution, however I've just tried using a TDBGrid,
>and once again the dreaded Key Violation has appeared.  I have tried
several
>modifications with the BDE configuration, and the ODBC configuration, and
>none has been successful.

>Any help on this would be greatly appreciated.   PLEASE duplicate the
>message to my email address in case it disappears in the newsgroup.

>Thanks,
>dfor...@execulink.com

Other Threads