易截截图软件、单文件、免安装、纯绿色、仅160KB

Delphi多线程学习:多线程数据库查询(ADO)

ADO多线程数据库查询通常会出现3个问题:
1、CoInitialize 没有调用
(CoInitialize was not
called);所以,在使用任何dbGo对象前,必须手
调用CoInitialize和CoUninitialize。调用CoInitialize失败会产生"CoInitialize was not
called"例外。
2、画布不允许绘画
(Canvas does not allow
drawing);所以,必须通过Synchronize过程来通知主线程访问主窗体上的任何控件。
3、不能使用主ADO连接
(Main TADoConnection cannot be
used!);所以,线程中不能使用主线程中TADOConnection对象,每个线程必须创建自己的数据库连接。
     Delphi2007安装后在X:\Program Files\Common Files\CodeGear
Shared\Data目录下有一个dbdemos.mdb文件,用来作为测试的例子。dbdemos.mdb中的customer表保存了客户信
息,orders表中保存了订单信息。
      
测试程序流程大致是这样的:在主窗体上放TADOConnection和TQuery控件,启动时这个TQuery从Customer表中查出客户编码
CustNo和公司名称Company,放到三个Combox框中,分别在三个列表框中选定客户公司名称,按照公司名称所对应的客户代码建立三个线程同时
在orders表中查询销售日期SaleDate分别填入ListBox中。
{主窗体代码}
unit
Main;
 
interface
 
uses
Windows,
Messages,
SysUtils,
Variants,
Classes,
Graphics,
Controls,
Forms,
Dialogs,
DB,
ADODB,
StdCtrls;
 
type
TForm2 =
class
(
TForm)
ComboBox1:
TComboBox;
ComboBox2:
TComboBox;
ComboBox3:
TComboBox;
ListBox1:
TListBox;
ListBox2:
TListBox;
ListBox3:
TListBox;
Button1:
TButton;
ADOConnection1:
TADOConnection;
ADOQuery1:
TADOQuery;
Label1:
TLabel;
Label2:
TLabel;
Label3:
TLabel;
procedure
FormCreate(
Sender:
TObject
)
;
procedure
Button1Click(
Sender:
TObject
)
;
private
{ Private declarations }
public
{ Public declarations }
end
;
 
var
Form2:
TForm2;
 
implementation
 
uses
ADOThread;
 
{$R *.dfm}
 
procedure
TForm2.
Button1Click
(
Sender:
TObject
)


相关文档:

Delphi 列出目录下的文件

function ListFiles(Dir: String):TStrings;
var
FSearchRec: TSearchRec;
FileList: TStrings;
FindResult: Integer;
begin
if Dir[length(Dir)]<>'\' then Dir:=Dir+'\';
FileList :=TStringList.Create;
FindResult:=FindFirst(Dir+'*.*,faAnyFile+faDirectory,FSearchRec);
while FindRes ......

Delphi的Socket编程要分几步?

Delphi的Socket编程要分几步?
2008-12-20 02:03:24
 标签:Delphi Socket 编程   [推送到技术圈]
ClientSocket 和ServerSocket
几个重要的属性:   
1.client和server都有port属性,需要一致才能互相通信   
2.client有Address属性,使用时填写对方(server)的IP地址  & ......

淘宝平台开发 delphi 示例

淘宝开放平台的开发例子大多都是c#,php,java等,缺少Pascal的例子。
现用delphi写了一个示例,
关键点是签名的生成,签名需按key字母顺序排序,并去掉等于号后首尾相连。
关键代码:
 memstr:= TMemoryStream.Create;
 //用授权码获取 session
  IdHTTP1.Get('http://container.api.tbsandbox.com/c ......

Delphi在Vasta/win 7下获取权限

毕竟Win32程序的开发,Delphi还是有顽强的生命力的。
操作步骤如下:
1.建立 res 文件
建立一个文本文件,名字可以自己起,我这里叫:UAC.manifest,内容:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号