Solved

Accessing a nested field...

Posted on 2002-05-11
4
663 Views
Last Modified: 2010-04-04
Hello,
i'm using TClientDataSet to read the data from a XML file.
I have a nested field and i need to access to its "subfields"... how can i do that through code?
I tried to read the help, it says something about using the TDatasetField class but i can't figure out how.
Let's say that i have something like this:


procedure Test;
var
 CDS: TClientDataSet;
begin
 CDS := TClientDataSet.Create(Self);  
 CDS.LoadFromFile('myfile.xml');      
 CDS.Active := True;                            
 if CDS.RecordCount > 0 then              
 begin  
  CDS.First;                                          
  //here i should read the subfields
  //of a nested field (let's call it
  //'mynestedfield')... how can i do this?
 end;
 CDS.Active := False;
 CDS.Free;
end;



Any suggestion is welcome.

Bye,
   Luca T.
0
Comment
Question by:lucat
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
nestorua earned 200 total points
ID: 7004396
HI, lucat,
I don't think it's reasonable to create datasetfield
in runtime. I think you can do it in design time using
Fields Editor of the First ClientDataSet (with the field of
datasefield type) and then simply set the datasetfield property of the Second ClientDataSet to this datasetfield.

But of course you can do it in runtime.
Do it as follows:
1.Create TDatasetField object.
2.Set its Fieldname property to that of the First ClientDataSet Field which is of DataSet type (in your notation 'mynestedfield').
3.Set its Dataset property to First ClientDataSet (don't forget it must be closed in this moment).
4.Set the datasetFiled property of the Second ClientDataset
to the created DattaSetField.
5.Open the First Clientdataset.
That's all.
Sincerely,
Nestorua.
0
 

Author Comment

by:lucat
ID: 7004955
Why is it unreasonable? I need it only to read from a XML file the translations of my menus and the settings when the program starts... then i don't need it anymore... why using comp memory and resources for something that i will not use anymore?

Anyway... can you show me an example?
Shouldn't be that field a persistent field to use it that way? How do i make a field become a persistent field through code to do it?

Thank you,
   Luca
0
 
LVL 4

Expert Comment

by:nestorua
ID: 7006736
HI, lucat,
Sure I can show you an example of what I said,
but first tell me what item of my proposal you can not realize?
I seemed to give you accurate plan what to do.
Sincerely,
Nestorua.
0
 
LVL 1

Expert Comment

by:pnh73
ID: 9005640
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept answer from nestorua

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Paul (pnh73)
EE Cleanup Volunteer
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now