TClIEntDataSet.Data { 數據的二進制格式的描述 }
TClIEntDataSet.XMLData { 數據的 XML 格式的描述 }
//先在窗體上放置 ClIEntDataSet1、Memo1 和三個按鈕
uses XMLDoc, IOUtils; { 分別提供 FormatXMLData 和 TFile.ReadAllText 函數 }
{ 設定當前目錄 }
procedure TForm1.FormCreate(Sender: TObject);
begin
ChDir(GetEnvironmentVariable('COMMONPROGRAMFILES') + '\CodeGear Shared\Data\');
end;
{ 讀取 XMLData 測試 }
procedure TForm1.Button1Click(Sender: TObject);
begin
ClIEntDataSet1.LoadFromFile('employee.cds');
Memo1.Text := FormatXMLData(ClIEntDataSet1.XMLData);
end;
{ 寫入 XMLData 測試 }
procedure TForm1.Button2Click(Sender: TObject);
var
str: string;
begin
str := TFile.ReadAllText('country.XML');
ClIEntDataSet1.XMLData := str;
Memo1.Text := FormatXMLData(ClIEntDataSet1.XMLData);
end;
{ 讀寫 Data 測試 }
procedure TForm1.Button3Click(Sender: TObject);
var
ClientDataSet2: TClIEntDataSet;
begin
ClientDataSet2 := TClIEntDataSet.Create(Self);
ClIEntDataSet2.LoadFromFile('parts.cds');
ClientDataSet1.Data := ClIEntDataSet2.Data;
ClIEntDataSet2.Free;
Memo1.Text := FormatXMLData(ClIEntDataSet1.XMLData);
end;