 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Brad Gies Guest
|
Posted: Tue Oct 14, 2003 9:56 pm Post subject: Strange Result in BeforeUpdateRecord. |
|
|
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 |
|
 |
|
|
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
|
|