请教如何用多线程同时向数据导入2个文本文件数据? ( 积分: 200 )

  • 主题发起人 主题发起人 ashow
  • 开始时间 开始时间
A

ashow

Unregistered / Unconfirmed
GUEST, unregistred user!
假如我有两或以上个文本文件需通过ado组件导入数据库,如何用多线程实现呢?
大家有相关的例子或文档吗?谢谢~
 
假如我有两或以上个文本文件需通过ado组件导入数据库,如何用多线程实现呢?
大家有相关的例子或文档吗?谢谢~
 
请大家帮个忙
 
Multithread Database Programming
unit unPrepareDataset;
interface
uses
Classes, DB, ADODB,AdoConEd;
type
TInitializeDataSet = class(TThread)
private
FDataModule:TDataModule;
FUnActiveDataSet:TDataSet;
procedure OpenDataSet;
protected
procedure Execute;
override;
public
constructor Create(DataModule:TDataModule);
end;

implementation
constructor TInitializeDataSet.Create(DataModule: TDataModule);
begin
inherited Create(True);
FDataModule:=DataModule;
Self.OnTerminate:=OnTerminate;
FreeOnTerminate := True;
Resume;
end;

procedure TInitializeDataSet.Execute;
var
i:integer;
begin
with FDataModuledo
begin
for i:=0 to ComponentCount-1do
begin
if (Components is TADOTable) then
begin
FUnActiveDataSet:=(Components as TDataSet);
Synchronize(OpenDataSet);
end;
end;
end;

end;

procedure TInitializeDataSet.OpenDataSet;
begin
FUnActiveDataSet.Open;
end;

end.
 
后退
顶部