$200 Wanted it! 请教Delphi多线程同步处理多个存储过程?

leon2000 2000-08-25 05:23:00
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;
close;
end;
end;

procedure spThread.Execute;
var i:integer;
begin
{ Place thread code here }
synchronize(disLoop);
if Terminated then exit;
end;

end.

3. 是否要使用Tsession?

...全文
73 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Sayhigh 2000-08-25
  • 打赏
  • 举报
回复
如果是无返回结果集Sql如Update之类的不要用Open,用其他的方式比如Exec....Sorry忘了看帮助吧.
ccpyccpy 2000-08-25
  • 打赏
  • 举报
回复
关注

5,386

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧