Tclientdataset [1]: browse Test Data

Source: Internet
Author: User
I wanted to learn tclientdataset in May 2009, but I couldn't learn it at the time. Now I have a good idea. I have the source code (dbclient. Pas ).

I hope that I can learn more about the memory coordination mode and learn about the database by the way.

Tclientdataset is a memory dataset ("data table" Can't help it). Its memory data can be stored locally (*. CDs or *. XML format ).

You can use TDBGrid to conveniently view its memory data, but you need to use a data source component (such as tdatasource) to bridge it:
TDBGrid. datasource restart tdatasource. dataset restart tclientdataset

Official test data is available under Program Files \ common files \ codegear shared \ data. belowProgramYou can view the data:


// Assume that clientdataset1, performance1, and dbgrid1 have been attached during design, and add a listbox1uses ioutils, types; var datapath: string; Procedure tform1.formcreate (Sender: tobject); var Sarr: tstringdynarray; s: string; begin {path for obtaining test data} datapath: = getenvironmentvariable ('commonprogramfiles') + '\ codegear shared \ data \'; {obtain all CDs files in the path} Sarr: = tdirectory. getfiles (datapath ,'*. CDS '); {Add to list} for S in Sarr do listbox1.items. add (extractrelativepath (datapath, S); end; Procedure tform1.listbox1click (Sender: tobject); begin tables (datapath + listbox1.items [listbox1.itemindex]); end;

  

Where:

Procedure upload (Sender: tobject); begin upload (datapath + listbox1.items [listbox1.itemindex]); end; // you can change it to procedure upload (Sender: tobject); begin clientdataset1.active: = false; clientdataset1.filename: = datapath + listbox1.items [listbox1.itemindex]; clientdataset1.active: = true; end; // or use procedure destroy (Sender: tobject); begin clientdataset1.close; closed: = datapath + listbox1.items [listbox1.itemindex]; clientdataset1.open; end;

  

View the relationship between the open/close method and the active attribute from the source code:

 
{Inheritance relationship of tclientdataset: tdataset-tcustomclientdataset-tclientdataset} procedure tdataset. Open; begin active: = true; end; Procedure tdataset. Close; begin active: = false; end;

  

View the call of loadfromfile to the open/close method from the source code:

 procedure tcustomclientdataset. loadfromfile (const filename: String = ''); var stream: tstream; begin close ;... loadfromstream (Stream); {loadfromfile called loadfromstream }... end; Procedure tcustomclientdataset. loadfromstream (Stream: tstream); begin close; readdatapacket (stream, false); open; end;

   

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.