Re: Delphi 6 - ADO - MS SQL Server
- From: "AquaGrrlll" <gnome@xxxxxxxxx>
- Date: Fri, 22 Sep 2006 16:44:05 +0100
"Angus Robertson - Magenta Systems Ltd" <angus@xxxxxxxxxxxx> wrote in
message news:memo.20060922140857.1528A@xxxxxxxxxxxxxxx
You need to create a FIFO queue for your SQL statements, using a
message triggered from the ExecuteComplete event (where you must
check the result of each async operation) to execute the next
statement.
When I set up the thread I give it it's own TADOConnection as well as the
TADOStoredProc:
FConnection := TADOConnection.Create(nil);
FConnection.ConnectionString := FConnectionStr;
FConnection.OnExecuteComplete := ConnectionExecuteComplete;
FExecuteComplete := True;
FUpdateIndividualProc := TADOStoredProc.Create(nil);
FUpdateIndividualProc.Connection := FConnection;
FUpdateIndividualProc.ProcedureName := 'dpersUpdateIndividual';
FUpdateIndividualProc.ExecuteOptions := [eoAsyncExecute];
FUpdateIndividualProc.Parameters.Refresh;
with the procedure ConnectionExecuteComplete setting FExecuteComplete to
True;
The following is called by the execute of the thread in a loop:
procedure TCRMIndividualThread.UpdateIndividual;
begin
while not FExecuteComplete and not Terminated do
Sleep(5);
//Fill in params of StoredProc
FExecuteComplete := False;
FUpdateIndividualProc.ExecProc;
end;
So the first time, FExecuteComplete is True, the stored procedure is
executed. Theoretically, the OnExecuteComplete of the connection will fire
when the command has been completed, FExecuteComplete is set to True and
around we go again. If the loop's a bit too fast the Sleep will keep
everything on hold until the connection says that the command has been
executed.
Problem is, that isn't happening. OnExecuteComplete never fires and the
whole thing hangs.
Any ideas why?
.
- Follow-Ups:
- Re: Delphi 6 - ADO - MS SQL Server
- From: Angus Robertson - Magenta Systems Ltd
- Re: Delphi 6 - ADO - MS SQL Server
- From: AquaGrrlll
- Re: Delphi 6 - ADO - MS SQL Server
- References:
- Re: Delphi 6 - ADO - MS SQL Server
- From: AquaGrrlll
- Re: Delphi 6 - ADO - MS SQL Server
- From: Angus Robertson - Magenta Systems Ltd
- Re: Delphi 6 - ADO - MS SQL Server
- Prev by Date: Re: ADO - ClientDataSet - Master/Detail
- Next by Date: Re: ADO - ClientDataSet - Master/Detail
- Previous by thread: Re: Delphi 6 - ADO - MS SQL Server
- Next by thread: Re: Delphi 6 - ADO - MS SQL Server
- Index(es):