Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem: "Key Violation" with ClientDataSet

128 views
Skip to first unread message

Rui Filipe Ribeiro

unread,
Mar 25, 2003, 8:54:58 PM3/25/03
to
Hi,

I'm using TSQLDataSet -> TDataSetProvider -> TClientDataSet.
I set Provider.UpdateMode=upWhereKeyOnly.
In the TSQLDataSet I set ProviderFlags=[pfInUpdate,pfInWhere,pfInKey] only
in the first field (the primary key field).
In the ClientDataSet I set ProviderFlags=[pfUpdate,pfWhere] in all fields.
In the ClientDataSet.OnNewRecord I set zero to the key field to initialize
it.

My problem happens when I try to post a second record on the ClientDataSet.
I obtain a "Key Violation" message. I don't have any KeyFields defined in
the ClientDataSet. If the ClientDataSet is working in memory, why it uses
definitions of the SQLDataSet?
I want to set the key field only when I apply the updates to all records,
because before I don't know if the user wants to cancel everything.

Thanks to all,

RFR

Bill Todd

unread,
Mar 25, 2003, 9:16:46 PM3/25/03
to
Don't set the ProviderFlags for the CDS. They are set automatically
when the CDS is opened.

On Wed, 26 Mar 2003 01:54:58 -0000, "Rui Filipe Ribeiro"
<ruifilip...@mail.telepac.pt> wrote:

>Hi,
>
>I'm using TSQLDataSet -> TDataSetProvider -> TClientDataSet.
>I set Provider.UpdateMode=upWhereKeyOnly.
>In the TSQLDataSet I set ProviderFlags=[pfInUpdate,pfInWhere,pfInKey] only
>in the first field (the primary key field).
>In the ClientDataSet I set ProviderFlags=[pfUpdate,pfWhere] in all fields.
>In the ClientDataSet.OnNewRecord I set zero to the key field to initialize
>it.
>
>My problem happens when I try to post a second record on the ClientDataSet.
>I obtain a "Key Violation" message. I don't have any KeyFields defined in

If you post two records with the same primary key value you do have a
key violation.<g> The CDS tries to mimic the constraints of the
database you are connected to. The best way to handle this depends on
what database you are using. Since I do not know that the best I can
do is refer you to
http://bdn.borland.com/article/0,1410,20847,00.html.


--
Bill (TeamB)
(TeamB cannot respond to questions received via email)

Dave Rowntree

unread,
Mar 26, 2003, 4:32:45 AM3/26/03
to
See if this helps (watch out for url wrap):
http://www.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=3e6e6a8d%40
newsgroups.borland.com&rnum=1&prev=/groups%3Fas_q%3DProviderFlags%26safe%3Di
mages%26ie%3DUTF-8%26oe%3DUTF-8%26as_uauthors%3DDave%2520Rowntree%26as_drrb%
3Dq%26as_qdr%3Dm%26lr%3D%26hl%3Den

--
Dave Rowntree
"Rui Filipe Ribeiro" <ruifilip...@mail.telepac.pt> wrote in message
news:3e81...@newsgroups.borland.com...

Rui Filipe Ribeiro

unread,
Mar 28, 2003, 3:58:05 AM3/28/03
to
Thanks.
With your help I increased my knowledge about dbxepress, also I resolved my
problem.

RFR

"Rui Filipe Ribeiro" <ruifilip...@mail.telepac.pt> escreveu na mensagem
news:3e81...@newsgroups.borland.com...

0 new messages