BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Strange Result in BeforeUpdateRecord.

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Multi-Tier)
View previous topic :: View next topic  
Author Message
Brad Gies
Guest





PostPosted: Tue Oct 14, 2003 9:56 pm    Post subject: Strange Result in BeforeUpdateRecord. Reply with quote



I've just sent a fairly long post under the subect of Validating
Inserts/Updates in Remote Data module if anyone needs to know something
about what I'm doing to answer the question below.


I noticed on at least two or three occassions when I modified a detail
record (using Nested tables) and there are more than one detail records that
the updates seemed to get mixed up. I modified a "Quantity" field on the
second detail record, but left the "UnitPrice" field blank, and then in the
BeforeUpdateRecord the "Unit Price" for the first detail record appeared
with the modified Quantity of the second detail record. This might be
explained by the fact that I created a temporary ClientDataSet, used
CloneCursor on the detail table, and iterated through the record set to add
up the totals of Quantity * UnitPrice and then modify the Master record with
the updated totals, and then free the temporary clientdataset. Note that
everything looks fine in the grid before I ApplyUpdates, but in the
BeforeUpdateRecord event, the fields seem to be mixed sometimes. I will try
to assign .Data tomorrow and see if that works better.

Below is the code I've been using, if anyone sees any obvious errors: Would
this code change the cursor in the passed in DataSet ??

function GetDataSetTotal(DataSet : TClientDataSet; FloatFieldToTotal :
string) : real;
var
CdsClone : TClientDataSet;
begin
cdsClone := TClientDataSet.Create(nil);
try
cdsClone.CloneCursor(DataSet, false, false );
cdsClone.First;
Result := 0.00;
while not cdsClone.Eof do
begin
Result := Result + cdsClone.FieldByName(FloatFieldToTotal).AsFloat;
cdsClone.Next;
end;

finally
cdsClone.Free;
end;
end;


Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Multi-Tier) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.