易截截图软件、单文件、免安装、纯绿色、仅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调用VC++6.0编写的Dll

用VC++6.0编写了一个简单的dll,里面包含一个减法函数subtract(int a,int b),Dll命名为ff.Dll
代码如下:
1.ff.cpp:
// ff.cpp : Defines the entry point for the DLL application.
//
#include "StdAfx.h"
#include "ff.h"
BOOL APIENTRY DllMain( HANDLE hModule,
        ......

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三层架构

三层架构指的是界面,业务逻辑和数据存储分离,不是指物理上是否分离。
这样做的好处是层次分明,维护好做,系统资源也好分布式处理。
数据库层哪就不说了,用MSSQL、Orcale随你了,就是数据服务层
业务逻辑的话要分析清楚,就是中间层
界面,也叫客户端。这里就是得到数据和显示数据的部分了,不做其它处理。但是数据有 ......

Delphi to Excel 一些方法

一)   使用动态创建的方法   
  
  首先创建   Excel   对象,使用ComObj: 
  var   ExcelApp:   Variant; 
  ExcelApp   :=   CreateOleObject(   'Excel.Application'  ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号