zoukankan      html  css  js  c++  java
  • TClientDataSet的操作

    记性不好了,唉,这里写个被忘
    unit Unit1;

    interface

    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, Grids, DBGrids, DB, DBClient, StdCtrls;

    type
      TForm1 
    = class(TForm)
        Button1: TButton;
        Button2: TButton;
        ClientDataSet1: TClientDataSet;
        DataSource1: TDataSource;
        DBGrid1: TDBGrid;
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
      
    private
        
    { Private declarations }
      
    public
        
    { Public declarations }
      end;

    var
      Form1: TForm1;

    implementation

    {$R *.dfm}

    procedure TForm1.Button2Click(Sender: TObject);
    begin
      ClientDataSet1.LoadFromFile(
    'E:\TEMP.XML');
    end;


    procedure TForm1.Button1Click(Sender: TObject);
    var  tempClientDataSet : TClientDataSet;
    begin
    tempClientDataSet :
    = TClientDataSet.Create(self);
    try    with tempClientDataSet do
      begin
            with FieldDefs.AddFieldDef 
    do
            begin
                   DataType :
    = ftInteger;
                   Name     :
    = 'Field1';
            end;
            with FieldDefs.AddFieldDef 
    do
            begin
                   DataType :
    = ftdatetime;
                   Name     :
    = 'Field2';
            end;
            createDataSet;
            appendRecord([
    3,now]);
            appendRecord([
    1,now]);
            appendRecord([
    2,now]);
            tempClientDataSet.AddIndex(
    'T1''Field1', []);
            tempClientDataSet.IndexName :
    = 'T1';
            first;
            
    while not EOF do
              begin
                  showmessage(intToStr(FieldByName(
    'Field1').AsInteger)+formatdatetime('yyyymmdd HH:NN:DD',FieldByName('Field2').AsDateTime ));
                  next;
              end;
            end;
            tempClientDataSet.SaveToFile(
    'E:\TEMP.XML');
      
    finally
      tempClientDataSet.Free;
    end;
    end;



    end.
  • 相关阅读:
    40种网页常用小技巧(javascript)
    伸缩效果
    震动的超链
    一个模仿图片透明渐变做的表格颜色渐变效果
    荧 光 效 果
    用LoadRunner编写socket应用的测试脚本
    突发奇想写的一篇小科幻(如果可以叫做科幻的话)
    《软件性能测试过程详解与案例剖析》一书在Chinapub上8月份的销售排名持续上升
    建立高效的测试团队
    探索性测试(Exploratory Testing)概述
  • 原文地址:https://www.cnblogs.com/enli/p/642359.html
Copyright © 2011-2022 走看看