惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The Cloudflare Blog
Microsoft Security Blog
Microsoft Security Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
L
LangChain Blog
W
WeLiveSecurity
P
Proofpoint News Feed
月光博客
月光博客
NISL@THU
NISL@THU
L
LINUX DO - 最新话题
Webroot Blog
Webroot Blog
T
Threatpost
Y
Y Combinator Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
T
Threat Research - Cisco Blogs
Vercel News
Vercel News
Jina AI
Jina AI
阮一峰的网络日志
阮一峰的网络日志
S
Schneier on Security
J
Java Code Geeks
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
小众软件
小众软件
MyScale Blog
MyScale Blog
N
News and Events Feed by Topic
Stack Overflow Blog
Stack Overflow Blog
有赞技术团队
有赞技术团队
The Hacker News
The Hacker News
Schneier on Security
Schneier on Security
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Help Net Security
Help Net Security
Recent Announcements
Recent Announcements
S
Security @ Cisco Blogs
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Securelist
T
The Exploit Database - CXSecurity.com
云风的 BLOG
云风的 BLOG
C
Cisco Blogs
雷峰网
雷峰网
量子位
Google DeepMind News
Google DeepMind News
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Spread Privacy
Spread Privacy
L
Lohrmann on Cybersecurity
I
Intezer
T
The Blog of Author Tim Ferriss
G
GRAHAM CLULEY
D
DataBreaches.Net
V
Vulnerabilities – Threatpost
P
Privacy & Cybersecurity Law Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
罗磊的独立博客

博客园 - 万一

关于内存数据与 JSON 高亮 TRichEdit 当前行 使用 IntraWeb (45) - 活用 IntraWeb 使用 IntraWeb (43) - 测试读取 SqLite (二) 使用 IntraWeb (42) - 测试读取 SqLite (一) 使用 IntraWeb (41) - 数据控件速查 使用 IntraWeb (40) - 自定义 Session 数据 使用 IntraWeb (39) - THttpRequest、THttpReply 使用 IntraWeb (38) - TIWAppForm、TIWForm、TIWBaseHTMLForm、TIWBaseForm 使用 IntraWeb (37) - TIWApplication 使用 IntraWeb (36) - TIWServerControllerBase 使用 IntraWeb (35) - TIWJQueryWidget 使用 IntraWeb (34) - TIWAJAXNotifier 使用 IntraWeb (33) - Cookie 使用 IntraWeb (32) - Url 映射与 THandlers 使用 IntraWeb (31) - IntraWeb 的 Xml 操作使用的是 NativeXml 使用 IntraWeb (30) - TIWAppInfo、TIWMimeTypes、TIWAppCache 使用 IntraWeb (29) - 基本控件之 TIWAutherList、TIWAutherINI、TIWAutherEvent 使用 IntraWeb (28) - 基本控件之 TIWTemplateProcessorHTML、TIWLayoutMgrHTML、TIWLayoutMgrForm
使用 IntraWeb (44) - 测试读取 SqLite (三)
万一 · 2014-06-28 · via 博客园 - 万一

使用数据连接池(TIWDataModulePool).


新建工程时勾选 Pool Data Connections:


新增的 Pool(TIWDataModulePool) 被放在 ServerController 的窗体上(其实它也是个数据模块), 需要知道的变化是它增加了两个函数:


function LockDataModule: TDataModule1;
procedure UnlockDataModule(ADataModule: TDataModule1);

同时 Wizard 还自动生成了一个专门的数据模块 DataModuleUnit;
先把数据源相关控件放在 DataModuleUnit 的窗体上:


FDPhysSQLiteDriverLink1: TFDPhysSQLiteDriverLink;
FDGUIxWaitCursor1: TFDGUIxWaitCursor;
FDConnection1: TFDConnection;
DataSource1: TDataSource;
FDTable1: TFDTable;

然后在其 OnCreate 事件中写代码:


procedure TDataModule1.DataModuleCreate(Sender: TObject);
begin
  FDTable1.Connection := FDConnection1;
  DataSource1.DataSet := FDTable1;

  FDConnection1.DriverName := 'SQLite';
  FDConnection1.Params.Add('Database=FDDemo.sdb'); //别忘了把 FDDemo.sdb 复制到程序目录下

  FDTable1.TableName := 'Orders';
//  FDTable1.Active := True;
end;

最后回到主窗体, 先放个 IWDBGrid1: TIWDBGrid; 然后写代码:


uses DataModuleUnit, ServerController;

procedure TIWForm1.IWAppFormCreate(Sender: TObject);
var
  fDataModule: TDataModule1;
begin
  fDataModule := LockDataModule;
  IWDBGrid1.DataSource := fDataModule.DataSource1;
  fDataModule.FDTable1.Active := True;
  UnlockDataModule(fDataModule);

  IWDBGrid1.Align := alClient;
end;

效果图: