ISAPI TWebModule sluggish/hung after successful first query via TDataSetTableProducer


2005-03-25 09:42:45 PM
delphi65
I have a delphi 7 ISAPI TWebModule DLL producing a page with a
TDataSetTableProducer linked to a TADOQuery linked to a
TADOConnection. The first time the page is hit, the response comes
back "instantly" but then:
(a) Subsequent responses take 30s - 1min
(b) A separate tried-and-tested DLL which uses the same database seems
to stop responding at all
Somehow, the database connection or some part of the web server seems
to have hung/slowed after the page is hit the first time.
TIA for any clue!
Julian Brewer
PS. Please ignore the heavy-handed code, I was making everything
explicit "just in case" something syntactical was causing the bug.
=== === ===
unit main;
interface
uses
SysUtils, Classes, HTTPApp, DBWeb, DBXpressWeb, DB, ADODB, HTTPProd,
DSProd;
type
TWebModule1 = class(TWebModule)
Query1: TADOQuery;
ADOConnection1: TADOConnection;
DataSetTableProducer1: TDataSetTableProducer;
procedure WebModule1waOrderSummaryAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled:
Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
WebModule1: TWebModule1;
implementation
{$R *.dfm}
procedure TWebModule1.WebModule1waOrderSummaryAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
begin
try
with query1, sql do
begin
query1.close;
sql.clear;
add('SELECT O.Item, I.Description, SUM(O.Units) AS Units,
SUM(O.Units * O.UnitQty) AS QTY');
add('FROM srvStockOrders AS O, srvStockItems AS I');
add('WHERE O.Item=I.Item And O.Units>0 And
O.DeliveryDate>#04/20/2005# And O.DeliveryDate<#05/20/2005#');
add('GROUP BY O.Item, I.Description');
query1.open;
datasettableproducer1.DataSet := query1;
response.Content := 'Order Summary for April/May 2005
Delivery:<BR><BR>'+
datasettableproducer1.Content +
'<BR><BR>*** IMPORTANT ***'+
'<BR><BR>Data produced: ' +
formatDateTime('d mmm yyyy, hh:mm:ss
"(Server Time)"',now)+
'<BR><BR>To update the report, refresh
the page in your browser.';
datasettableproducer1.DataSet := nil;
query1.close;
query1.SQL.Clear;
end;
except
on e: exception do
begin
response.Content := e.Message;
try
Query1.Close;
except
end;
end;
end;
handled := true;
end;
end.
=== === ===
library OrgWebRep;
uses
ComInit in 'ComInit.pas',
ActiveX,
ComObj,
WebBroker,
ISAPIThreadPool,
ISAPIApp,
main in 'main.pas' {WebModule1: TWebModule};
{$R *.res}
exports
GetExtensionVersion,
HttpExtensionProc,
TerminateExtension;
begin
CoInitFlags := COINIT_MULTITHREADED;
Application.Initialize;
Application.CreateForm(TWebModule1, WebModule1);
Application.Run;
end.