Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Midas/TClientDataSet    [ Add a report in this area ]  
Report #:  38984   Status: Open
Close and CreateDataSet with TClientDataSet gives an Error when using InternalCalc Fields
Project:  Delphi Build #:  10.0.2288.42451
Version:    10.0 Submitted By:   Roeland Van Heddegem
Report Type:  Basic functionality failure Date Reported:  1/19/2007 4:11:00 AM
Severity:    Commonly encountered problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All versions Internal Tracking #:   266441
Resolution: None (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: (1 Total Rating)
2.00 out of 5
Total Votes: 11
Description
First, this rapport is very similar to 5483.

BUT, I expect that I can do a

with ClientDataSet do
begin
  ...
  Close;
  CreateDataSet;
   ...
end;

(at runtime) without any problems.

Now this is not possible if that TClientDataSet has a InternalCalc Field.

Solution:

Close should clear the InternalCalc FieldDefs!


Additional Comments:

I did this because I ran in another error with EmptyDataSet. (see error rapport 30648)
Steps to Reproduce:
1) Place a TClientDataSet on a Form
2) Add a Field as Data:  eg 'ID'
3) Copy/ Paste this ClientDataSet
4) Add a InternalCalc Field to this second ClientDataSet

5) Execute the following code:

ClientDataSet1.Close;
ClientDataSet1.CreateDataSet;

ClientDataSet1.Close;
ClientDataSet1.CreateDataSet;

// Everything works

ClientDataSet2.Close;
ClientDataSet2.CreateDataSet;

ClientDataSet2.Close;
ClientDataSet2.CreateDataSet;

// GIVES ERROR 'Name not unique in this context'
Workarounds
Clear the FieldDefs IF you are using persistent fields!

  Close;
  FieldDefs.Clear;  // Add this line
  CreateDataSet;

The best is of course to only remove the InternalCalc FieldDefs....
Attachment
CloseAndCreate.zip
Comments

Leslie Kaye at 2/1/2007 12:46:28 AM -
I cannot reproduce this error as described (same version of BDS2006) however I think there is a general problem in that changes to any existing Field (e.g. in the Fields Editor) following a CreateDataset are not reflected in the FieldDefs. Subsequently the mis-match between Field and the FieldDef causes a variety of design time errors. I have submitted my own report which agrees with your workaround that FieldDefs should be deleted prior to all Field edits.

Leslie Kaye at 2/1/2007 1:04:27 AM -
The Report 5483 refers to Internal Calculated Fields (rather than Calculated Fields as in this report). This is a reproducable error. 5483 is closed as "as designed". Perhaps someone could comment as to why it should be "designed" to throw this error?

Roeland Van Heddegem at 2/14/2007 12:28:26 AM -
You are right. My report must refer to InternalCalc Fields too. I have edited my report.
Thanks for checking this!

jesu ortega at 1/14/2008 12:50:32 AM -
Same bug in Delphi7

Server Response from: ETNACODE01