Einzelnen Beitrag anzeigen

MisterAHA

Registriert seit: 8. Mär 2008
7 Beiträge
 
#1

EMySqlException "ReceiveHeader: Net packets out of orde

  Alt 1. Feb 2009, 01:29
Datenbank: MYSQL • Version: 5.1 • Zugriff über: myduc
"ReceiveHeader: Net packets out of order: received[1], expected[2]"

Multiple MyCommands over one MyConnection.
Only one connection can be used because there are temporary tables.

Delphi-Quellcode:
-------------- snip -------------
type SQLQueryThread=class(TThread)
private
sqlstr:ansistring;
public
constructor Create(querystr:ansistring);
procedure Execute; override;
destructor Destroy; override;
end;

var sema_threads_running,sema_threads_completed:integer;

constructor SQLQueryThread.Create(querystr:ansistring);
begin
inherited Create(false);
sqlstr:=querystr;
inc(sema_threads_running);
end;

procedure SQLQueryThread.Execute;
var dbcmd:TMyCommand;
begin
dbcmd:=TMyCommand.Create(frm_search_database);
dbcmd.CommandTimeout:=3000;
dbcmd.ParamCheck:=false;
dbcmd.Prepared:=false;
dbcmd.Connection:=frm_main.MyConnection1;
dbcmd.SQL.Add(sqlstr);
dbcmd.Execute;
dbcmd.Free;
end;

destructor SQLQueryThread.Destroy;
begin
dec(sema_threads_running);
inc(sema_threads_completed);
inherited Destroy;
end;


//this part uses the threads

progressbar1.Maximum:=sqlcommandlist.Count-1;
sema_threads_running:=0;
sema_threads_completed:=0;
for i:=0 to sqlcommandlist.Count-1 do
begin
//alle befehle uebertragen
SQLQueryThread.Create(sqlcommandlist.Strings[i]);
repeat
application.ProcessMessages;
sleep(1);
until(sema_threads_running<maxquerythreads);
progressbar1.Position:=sema_threads_completed;
end;
repeat
application.ProcessMessages;
sleep(1);
progressbar1.Position:=sema_threads_completed;
until(sema_threads_running=0);
  Mit Zitat antworten Zitat