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.
查看全文
相关阅读:
空悬指针、野指针、内存泄漏、内存溢出
自定义消息的操作方法ON_MESSAGE(..)
为什么static成员变量一定要在类外初始化?
Ubuntu 系统目录结构
Beyond Compare 4 30天评估期结束的解决办法
C++ string 字符串 结尾 标志
C语言——枚举类型用法
结构体struct-联合体union-枚举enum
网卡bood
kvm 安装
原文地址:https://www.cnblogs.com/enli/p/642359.html
最新文章
第二次冲刺-个人工作总结08
第二次冲刺-个人工作总结07
第二次冲刺-个人工作总结06
06《软件需求模式》阅读笔记
05《软件需求模式》阅读笔记
04《软件需求模式》阅读笔记
03《软件需求模式》阅读笔记
02《软件需求模式》阅读笔记
01《软件需求模式》阅读笔记
问题账户需求分析
热门文章
2017年秋季个人阅读计划
读后感---我们应当怎样做需求分析
开发体会
C++ 自由存储区是否等价于堆
如何在博客园添加自己的头像
n个节点的二叉树有多少种形态
静态变量与全局变量的区别
C/C++中static的用法全局变量与局部变量
select、poll、epoll之间的区别
Hello World 是如何运行的
Copyright © 2011-2022 走看看