• delphi_ClientDataSet


    unit Unit1;

    interface

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

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

    var
    Form1: TForm1;

    implementation

    {$R *.dfm}

    procedure TForm1.Button1Click(Sender: TObject);
    var
    i:Integer;
    begin

    ClientDataSet1.Active :=False;
    ClientDataSet1.CreateDataSet;
    ClientDataSet1.IndexDefs.AddIndexDef.Fields :='ID';
    ClientDataSet1.IndexDefs.AddIndexDef.Name:='Idx_ID';

    ClientDataSet1.EmptyDataSet;
    ClientDataSet1.Active :=True;

    for i:=0 to 9 do
    begin
    ClientDataSet1.Append ;
    ClientDataSet1.fieldbyname('ID').Value :=i+1;
    ClientDataSet1.fieldbyname('Name').Value :=FormatFloat('000',i+1);
    ClientDataSet1.Post;
    end;

    end;

    end.

    --------------------------------

    object Form1: TForm1
    Left = 619
    Top = 377
    Width = 338
    Height = 393
    Caption = 'Form1'
    Color = clBtnFace
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -11
    Font.Name = 'MS Sans Serif'
    Font.Style = []
    OldCreateOrder = False
    PixelsPerInch = 96
    TextHeight = 13
    object DBGrid1: TDBGrid
    Left = 0
    Top = 0
    Width = 233
    Height = 355
    Align = alLeft
    DataSource = DataSource1
    ImeName = '中文(简体) - 搜狗拼音输入法'
    TabOrder = 0
    TitleFont.Charset = DEFAULT_CHARSET
    TitleFont.Color = clWindowText
    TitleFont.Height = -11
    TitleFont.Name = 'MS Sans Serif'
    TitleFont.Style = []
    end
    object Button1: TButton
    Left = 240
    Top = 160
    Width = 75
    Height = 25
    Caption = 'Button1'
    TabOrder = 1
    OnClick = Button1Click
    end
    object ClientDataSet1: TClientDataSet
    Aggregates = <>
    Params = <>
    Left = 192
    Top = 16
    object ClientDataSet1ID: TIntegerField
    FieldName = 'ID'
    end
    object ClientDataSet1Name: TStringField
    FieldName = 'Name'
    end
    end
    object DataSource1: TDataSource
    DataSet = ClientDataSet1
    Left = 112
    Top = 56
    end
    end

  • 相关阅读:
    Python字符串学习
    文本压缩版本三
    文件压缩版本二
    文件压缩(2)
    d17包,logging模块,hashlib模块 openpyxl模块,深浅拷贝
    d16 collections模块 时间模块 random模块 os模块 sys模块 序列化模块 subprocess模块
    d15 常用模块之正则模块
    14天 模块 , 导模块 , 循环导入, 相对,绝对导入, 项目目录规范,
    13t天 迭代器,生成器,内置函数
    55 jquery
  • 原文地址:https://www.cnblogs.com/dmqhjp/p/14244426.html
Copyright © 2020-2023  润新知