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

TClientDataSet problems

184 views
Skip to first unread message

Kristian Karlsson

unread,
Jun 13, 2002, 8:19:42 AM6/13/02
to
I dont know if this is the correct forum but maybe you could answer or
direct me to the correct new group.

TAdoQuery fetch data from Oracle.

The TClientDataSet gets data from the ADOQuery using a DataSetProvider.

When the changes are going to be saved to the database I have a set of
storeed procedures that i use to complete this task.
To know what should be done I set the filter on the ClientDataSet.

ClientDataSet.StatusFilter:=[usModified, usInserted, usDeleted];

While Not ClientDataSet.Eof Do
begin
if ClientDataSet.UpdateStatus=usModified then
begin
//Run Update Storeprocedure
end
//New
else if ClientDataSet.UpdateStatus=usInserted then
begin
//Run Insert Storeprocedure
end
//Delete
else if ClientDataSet.UpdateStatus=usDeleted then
begin
//Run Delete Storeprocedure
end;

ClientDataSet.Next;
end;

All this is working fine. The problem i have is when i creates a new row in
the grid and you forget to enter some data on that row so you go back to the
row again and fills in some more data.

Then this save loops got two insert status. The first contains the first set
of data the second row i conatins first and second data?
(only one new row in the grid but the loop above loops 2 times?)

Why is there 2 rows in the clientdataset? I only need one row with all data.
I havn't done any updates to the database or ApplyChanges... I dont get it!

Please give me ideas!

/Kristian Karlsson


John Pierce

unread,
Jun 13, 2002, 12:14:22 PM6/13/02
to
If I understand you correctly, you are using a bdGrid. When you add the
row the first time, and tab off it, the record is posted. If you do not
flag any of the columns as required, there will be no error message
generated. The second time around, you post again, and this is an
update. This is the problem. There are different ways to deal with it,
depending on your application.

John Pierce

Robert Cerny

unread,
Jun 13, 2002, 4:32:30 PM6/13/02
to
It's the way midas works, every post is logged as separate update. It's even
documented somewhere.
So, if you do number of updates to the same row, midas won't merge those
changes into one update, but will send each update as own
(update/insert/delete) statement.
Maybe there's a good reason for this.
A workaround would be to use old values of first record and new values of
last record (in delta).

--
Robert

Kristian Karlsson wrote in message <3d088cee$1_2@dnews>...

Kristian Karlsson

unread,
Jun 14, 2002, 2:47:52 AM6/14/02
to
okie that doesnt seem to be a good solution.

Possible ways out of this.
1) I ignore the ClientDataSet.StatusFilter:=[usModified, usInserted,
usDeleted]; row and goes through the complete
set and check UpdateStatus. It will go through a lot more rows but it works
Then I use ClientDataSet.StatusFilter:=[usDeleted] to remove the deleted
ones.

Works great!

2) Use the DataSetProvider.OnBeforeUpdateRecord and run my storeed
procedures there?
Does the OnBeforeUpdateRecord get one call per edit also?


"Robert Cerny" <robert.q...@neosys.xrs.qwe.si> wrote in message
news:aeb6i2...@neosys.xrs.si...

Kristian Karlsson

unread,
Jun 14, 2002, 2:42:57 AM6/14/02
to
Yes you have understand it correctly.

"John Pierce" <jpi...@healthplanning.com> wrote in message
news:3D08C4DE...@healthplanning.com...

0 new messages