$200 Wanted it!谁能给个多线程处理数据库的源代码!或请教Delphi多线程同步处理多个存储过程?
1.我在使用多线程时出现错误:raise execption class EnoResultSet with message
'Error creating cursor handle'
2.线程代码为
unit spThreadUnit;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Menus, StdCtrls, Buttons, ScktComp, ExtCtrls, ComCtrls, Db, DBTables,inifiles;
type
spThread = class(TThread)
private
{ Private declarations }
Asp:TStoredProc;
Askt:TCustomWinSocket;
protected
procedure Execute; override;
procedure DisLoop;
public
constructor Create(sp:TStoredProc;skt:TCustomWinSocket);
end;
implementation
{ Important: Methods and properties of objects in VCL can only be used in a
method called using Synchronize, for example,
Synchronize(UpdateCaption);
and UpdateCaption could look like,
procedure myThread.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }
{ myThread }
constructor spThread.Create(sp:TstoredProc;skt:TCustomWinSocket);
begin
inherited Create(False);
Asp:=sp;
Askt :=skt;
FreeonTerminate:=True;
end;
procedure spThread.DisLoop;
begin
// Aedit.text:=InttoStr(CurrentLoop);
with Asp do
begin
close;
open;
while not eof do
begin
Askt.SendText(fields[0].AsString+#13+#10);
next;
end;
//I am sure there is a record to return
end;
end;
procedure spThread.Execute;
var i:integer;
begin
{ Place thread code here }
synchronize(disLoop);
if Terminated then exit;
end;
end.
3. 是否要使用Tsession?