Robert Becskei
asked on
Delphi , Indy , AdoQuery / AdoStoredProcedure Thread
Hello Everyone , I am trying to create a small Webserver for internal usage . It is basicaly done and works wonderfully until a do a bit of stress testing on it . ( Firefox , Url : http://192.168.88.46:666/8231,12518,xxxx@yyyyy.com , and keep pressing F5 )
This is the part where I do the data processing with indy :
procedure TMain.IdHTTPServer1Command Get(AConte xt: TIdContext;
ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
var gestellname , kuid , email : string;
inputstring : TStringList;
temp : string;
// only used to check if kuid is valid
tempKuid , tempCode : integer;
begin
temp:=ARequestInfo.URI;
delete(temp,1,1);
inputstring := TStringList.Create;
inputstring.CommaText := temp;
// ado threaded
CoInitialize(nil); //CoInitialize was not called
if inputstring.Count = 3 then
begin
gestellname:=inputstring[0 ];
kuid:=inputstring[1];
email:=inputstring[2];
inputstring.Free;
val(kuid,tempKuid,tempCode );
if (length(gestellname) <= 50) and (length(kuid) <= 10) and (length(email) <= 50) and (tempCode = 0) then
begin
ResultQuery.ConnectionStri ng:='FILE NAME='+ExtractFilePath(App lication.E xeName)+'\ teutodb.ud l';
ResultQuery.CursorLocation := clUseServer;
ResultQuery.CursorType:= ctOpenForwardOnly;
if ResultQuery.Active then ResultQuery.Close;
ResultQuery.Parameters.Par amByName(' Gestellnam e').Value: =gestellna me;
ResultQuery.Parameters.Par amByName(' kuid').Val ue:=strtoi nt(kuid);
ResultQuery.Parameters.Par amByName(' Gestell'). Value:=ema il;
ResultQuery.Open;
if ResultQuery.RecordCount <> 0 then
begin
// ************************** ** LOG ************************** ********** *
spWebLog.ConnectionString: ='FILE NAME='+ExtractFilePath(App lication.E xeName)+'\ teutodb.ud l';
spWebLog.CursorLocation := clUseServer;
spWebLog.Parameters.ParamV alues['@Ku id']:=strt oint(kuid) ;
spWebLog.Parameters.ParamV alues['@Ke mail']:=em ail;
spWebLog.Parameters.ParamV alues['@Ge stellname' ]:=gestell name;
spWebLog.Parameters.ParamV alues['@Cl ientIP']:= ARequestIn fo.RemoteI P;
spWebLog.Parameters.ParamV alues['@Cl ientURL']: =ARequestI nfo.URI;
spWebLog.Parameters.ParamV alues['@Cl ientAgent' ]:=AReques tInfo.User Agent;
spWebLog.Parameters.ParamV alues['@Ty pe']:=0;
spWebLog.Parameters.ParamV alues['@Re questDate' ]:=date+ti me;
spWebLog.ExecProc;
// ************************** ** LOG ************************** ********** *
AResponseInfo.ContentText := '<html><head><title>Transp ort XLR - Mini Webserver</title></head>' +
'<body>Sehr geehrte Kunde,' +
'<br />' +
'<br />' +
'<br />------------------------ ---------- ---------- ---------- ---------- ---------- ---------- ---' +
'<br /><b>Gestellname:</b> ' + gestellname +
'<br /><b>Kunde Nr.:</b> ' + kuid + ' ('+ResultQueryKunde.Value+ ') ' +
'<br /><b>E-Mail:</b> ' + email +
'<br />------------------------ ---------- ---------- ---------- ---------- ---------- ---------- ---' +
'<br />' +
'<br />' +
'<br />Gestell '+gestellname+' Freigemeldet! Vielen Dank für Ihre Unterstützung! ' +
'<br />' +
'<br />' +
'<br />Mit Freudlichem Grüßen ' +
'<br />Transport XLR ' +
'<br />' +
'</body></html>';
// we mark the Rack free in our Database
spRack.ConnectionString:=' FILE NAME='+ExtractFilePath(App lication.E xeName)+'\ teutodb.ud l';
spRack.CursorLocation := clUseServer;
spRack.Parameters.ParamVal ues['@OP'] :='WEBMARK ';
spRack.Parameters.ParamVal ues['@Free ']:=1;
spRack.Parameters.ParamVal ues['@Free Date']:=da te+time;
spRack.Parameters.ParamVal ues['@Gest ellname']: =gestellna me;
spRack.ExecProc;
// we also insert an entry into the History of the Rack
spHist.ConnectionString:=' FILE NAME='+ExtractFilePath(App lication.E xeName)+'\ teutodb.ud l';
spHist.CursorLocation := clUseServer;
spHist.Parameters.ParamByN ame('@OP') .Value:='I NS';
spHist.Parameters.ParamByN ame('@Kuid ').Value:= strtoint(k uid);
spHist.Parameters.ParamByN ame('@Kund e').Value: =ResultQue ryKunde.Va lue;
spHist.Parameters.ParamByN ame('@Adre sse').Valu e:=ResultQ ueryAdress e.Value;
spHist.Parameters.ParamByN ame('@Ort' ).Value:=R esultQuery Ort.Value;
spHist.Parameters.ParamByN ame('@Plz' ).Value:=R esultQuery Plz.Value;
spHist.Parameters.ParamByN ame('@Land ').Value:= ResultQuer yLand.Valu e;
spHist.Parameters.ParamByN ame('@Lief erschein') .Value:=Re sultQueryL ieferschei n.Value;
spHist.Parameters.ParamByN ame('@LKW' ).Value:=' ';
spHist.Parameters.ParamByN ame('@OR_T OUR').Valu e:='';
spHist.Parameters.ParamByN ame('@Lief ertag').Va lue:='1899 -01-01';
spHist.Parameters.ParamByN ame('@Modi fier').Val ue:='[KUND E]';
spHist.Parameters.ParamByN ame('@Modi fyDate').V alue:=date +time;
spHist.Parameters.ParamByN ame('@gest ellname'). Value:=ges tellname;
spHist.Parameters.ParamByN ame('@Fehl ergrund'). Value:='';
spHist.Parameters.ParamByN ame('@Dire ction').Va lue:=0;
spHist.Parameters.ParamByN ame('@Plan nedFailed' ).Value:=0 ;
spHist.Parameters.ParamByN ame('@Rese t').Value: =0;
spHist.Parameters.ParamByN ame('@Cons truction') .Value:=0;
spHist.Parameters.ParamByN ame('@Comp uter').Val ue:='Trans port XLR Mini Webserver';
spHist.ExecProc
end
else
begin
// ************************** ** LOG ************************** ********** *
spWebLog.ConnectionString: ='FILE NAME='+ExtractFilePath(App lication.E xeName)+'\ teutodb.ud l';
spWebLog.CursorLocation := clUseServer;
spWebLog.Parameters.ParamV alues['@Ku id']:=strt oint(kuid) ;
spWebLog.Parameters.ParamV alues['@Ke mail']:=em ail;
spWebLog.Parameters.ParamV alues['@Ge stellname' ]:=gestell name;
spWebLog.Parameters.ParamV alues['@Cl ientIP']:= ARequestIn fo.RemoteI P;
spWebLog.Parameters.ParamV alues['@Cl ientURL']: =ARequestI nfo.URI;
spWebLog.Parameters.ParamV alues['@Cl ientAgent' ]:=AReques tInfo.User Agent;
spWebLog.Parameters.ParamV alues['@Ty pe']:=1;
spWebLog.Parameters.ParamV alues['@Re questDate' ]:=date+ti me;
spWebLog.ExecProc;
// ************************** ** LOG ************************** ********** *
AResponseInfo.ContentText := '<html><head><title>Transp ort XLR - Mini Webserver</title></head>' +
'<body>Sehr geehrte Kunde,' +
'<br />' +
'<br />' +
'<br />------------------------ ---------- ---------- ---------- ---------- ---------- ---------- ---' +
'<br />Die von Ihnen eingegebene Gestellnummer '+gestellname+' ist nicht länger Gültig ' +
'<br />------------------------ ---------- ---------- ---------- ---------- ---------- ---------- ---' +
'<br />' +
'<br />' +
'<br />Mit Freudlichem Grüßen ' +
'<br />Transport XLR ' +
'<br />' +
'</body></html>';
end;
end
else
begin
// ************************** ** LOG ************************** ********** *
// ************************** ** LOG ************************** ********** *
AResponseInfo.ContentText := '<html><head><title>Transp ort XLR - Mini Webserver</title></head>' +
'<body>Sehr geehrte Kunde,' +
'<br />' +
'<br />' +
'<br />------------------------ ---------- ---------- ---------- ---------- ---------- ---------- ---' +
'<br /><b>Eingabe Fehler</b> ' +
'<br />------------------------ ---------- ---------- ---------- ---------- ---------- ---------- ---' +
'<br />' +
'<br />' +
'<br />Mit Freudlichem Grüßen ' +
'<br />Transport XLR ' +
'<br />' +
'</body></html>';
end;
end
else
begin
// ************************** ** LOG ************************** ********** *
// ************************** ** LOG ************************** ********** *
AResponseInfo.ContentText := '<html><head><title>Transp ort XLR - Mini Webserver</title></head>' +
'<body>Sehr geehrte Kunde,' +
'<br />' +
'<br />' +
'<br />------------------------ ---------- ---------- ---------- ---------- ---------- ---------- ---' +
'<br /><b>Eingabe Fehler</b> ' +
'<br />------------------------ ---------- ---------- ---------- ---------- ---------- ---------- ---' +
'<br />' +
'<br />' +
'<br />Mit Freudlichem Grüßen ' +
'<br />Transport XLR ' +
'<br />' +
'</body></html>';
end;
CoUninitialize();
end;
The problem is when I keep pressing the F5 without releasing it , after a while I get the error :
The operation can not be processed while an asynchronous command is being executed
This is the part where I do the data processing with indy :
procedure TMain.IdHTTPServer1Command
ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
var gestellname , kuid , email : string;
inputstring : TStringList;
temp : string;
// only used to check if kuid is valid
tempKuid , tempCode : integer;
begin
temp:=ARequestInfo.URI;
delete(temp,1,1);
inputstring := TStringList.Create;
inputstring.CommaText := temp;
// ado threaded
CoInitialize(nil); //CoInitialize was not called
if inputstring.Count = 3 then
begin
gestellname:=inputstring[0
kuid:=inputstring[1];
email:=inputstring[2];
inputstring.Free;
val(kuid,tempKuid,tempCode
if (length(gestellname) <= 50) and (length(kuid) <= 10) and (length(email) <= 50) and (tempCode = 0) then
begin
ResultQuery.ConnectionStri
ResultQuery.CursorLocation
ResultQuery.CursorType:= ctOpenForwardOnly;
if ResultQuery.Active then ResultQuery.Close;
ResultQuery.Parameters.Par
ResultQuery.Parameters.Par
ResultQuery.Parameters.Par
ResultQuery.Open;
if ResultQuery.RecordCount <> 0 then
begin
// **************************
spWebLog.ConnectionString:
spWebLog.CursorLocation := clUseServer;
spWebLog.Parameters.ParamV
spWebLog.Parameters.ParamV
spWebLog.Parameters.ParamV
spWebLog.Parameters.ParamV
spWebLog.Parameters.ParamV
spWebLog.Parameters.ParamV
spWebLog.Parameters.ParamV
spWebLog.Parameters.ParamV
spWebLog.ExecProc;
// **************************
AResponseInfo.ContentText := '<html><head><title>Transp
'<body>Sehr geehrte Kunde,' +
'<br />' +
'<br />' +
'<br />------------------------
'<br /><b>Gestellname:</b> ' + gestellname +
'<br /><b>Kunde Nr.:</b> ' + kuid + ' ('+ResultQueryKunde.Value+
'<br /><b>E-Mail:</b> ' + email +
'<br />------------------------
'<br />' +
'<br />' +
'<br />Gestell '+gestellname+' Freigemeldet! Vielen Dank für Ihre Unterstützung! ' +
'<br />' +
'<br />' +
'<br />Mit Freudlichem Grüßen ' +
'<br />Transport XLR ' +
'<br />' +
'</body></html>';
// we mark the Rack free in our Database
spRack.ConnectionString:='
spRack.CursorLocation := clUseServer;
spRack.Parameters.ParamVal
spRack.Parameters.ParamVal
spRack.Parameters.ParamVal
spRack.Parameters.ParamVal
spRack.ExecProc;
// we also insert an entry into the History of the Rack
spHist.ConnectionString:='
spHist.CursorLocation := clUseServer;
spHist.Parameters.ParamByN
spHist.Parameters.ParamByN
spHist.Parameters.ParamByN
spHist.Parameters.ParamByN
spHist.Parameters.ParamByN
spHist.Parameters.ParamByN
spHist.Parameters.ParamByN
spHist.Parameters.ParamByN
spHist.Parameters.ParamByN
spHist.Parameters.ParamByN
spHist.Parameters.ParamByN
spHist.Parameters.ParamByN
spHist.Parameters.ParamByN
spHist.Parameters.ParamByN
spHist.Parameters.ParamByN
spHist.Parameters.ParamByN
spHist.Parameters.ParamByN
spHist.Parameters.ParamByN
spHist.Parameters.ParamByN
spHist.Parameters.ParamByN
spHist.ExecProc
end
else
begin
// **************************
spWebLog.ConnectionString:
spWebLog.CursorLocation := clUseServer;
spWebLog.Parameters.ParamV
spWebLog.Parameters.ParamV
spWebLog.Parameters.ParamV
spWebLog.Parameters.ParamV
spWebLog.Parameters.ParamV
spWebLog.Parameters.ParamV
spWebLog.Parameters.ParamV
spWebLog.Parameters.ParamV
spWebLog.ExecProc;
// **************************
AResponseInfo.ContentText := '<html><head><title>Transp
'<body>Sehr geehrte Kunde,' +
'<br />' +
'<br />' +
'<br />------------------------
'<br />Die von Ihnen eingegebene Gestellnummer '+gestellname+' ist nicht länger Gültig ' +
'<br />------------------------
'<br />' +
'<br />' +
'<br />Mit Freudlichem Grüßen ' +
'<br />Transport XLR ' +
'<br />' +
'</body></html>';
end;
end
else
begin
// **************************
// **************************
AResponseInfo.ContentText := '<html><head><title>Transp
'<body>Sehr geehrte Kunde,' +
'<br />' +
'<br />' +
'<br />------------------------
'<br /><b>Eingabe Fehler</b> ' +
'<br />------------------------
'<br />' +
'<br />' +
'<br />Mit Freudlichem Grüßen ' +
'<br />Transport XLR ' +
'<br />' +
'</body></html>';
end;
end
else
begin
// **************************
// **************************
AResponseInfo.ContentText := '<html><head><title>Transp
'<body>Sehr geehrte Kunde,' +
'<br />' +
'<br />' +
'<br />------------------------
'<br /><b>Eingabe Fehler</b> ' +
'<br />------------------------
'<br />' +
'<br />' +
'<br />Mit Freudlichem Grüßen ' +
'<br />Transport XLR ' +
'<br />' +
'</body></html>';
end;
CoUninitialize();
end;
The problem is when I keep pressing the F5 without releasing it , after a while I get the error :
The operation can not be processed while an asynchronous command is being executed
ASKER
Hi Geert,
Thank you but highly unlikely ... if I send the following url to the Webserver : http://192.168.88.46:666/
then the Static Webpage is executed. If I keep pressing the key for 30 minutes , did it just now. I still wont get an error .
The error comes from the AdoQuery , if I comment everything out and just leave the AdoQuery I get the error. Meanwhile I've altered the code a bit. I created the Query on the fly .
if inputstring.Count = 3 then
begin
// query and later stored procedures
end
else
begin
// shows static webpage
end;
Here the complete source again , altered :
procedure TMain.IdHTTPServer1Command Get(AConte xt: TIdContext;
ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
var gestellname , kuid , email : string;
inputstring : TStringList;
temp : string;
// only used to check if kuid is valid
tempKuid , tempCode : integer;
// ado connection threaded
Qry : TADOQuery;
myConnect : TADOConnection;
begin
temp:=ARequestInfo.URI;
delete(temp,1,1);
inputstring := TStringList.Create;
inputstring.CommaText := temp;
if inputstring.Count = 3 then
begin
gestellname:=inputstring[0 ];
kuid:=inputstring[1];
email:=inputstring[2];
inputstring.Free;
val(kuid,tempKuid,tempCode );
if (length(gestellname) <= 50) and (length(kuid) <= 10) and (length(email) <= 50) and (tempCode = 0) then
begin
CoInitialize(nil);
Qry := TADOQuery.Create(nil);
try
Qry.ConnectionString:='FIL E NAME='+ExtractFilePath(App lication.E xeName)+'\ teutodb.ud l';
Qry.CursorLocation:= clUseServer;
Qry.LockType := ltReadOnly;
if Qry.Active then Qry.Close;
Qry.SQL.Clear;
Qry.SQL.Add('select GestellName,Typ,Kuid,Kunde ,Adresse,O rt,PLZ,Lan d,Werk,Gla eser,Liefe rschein,LK W,OR_TOUR, ');
Qry.SQL.Add('convert(varch ar,cast(Li efertag as Date),104) as Liefertag,c2.Modifier,c2.M odifyDate, c2.Compute r,');
Qry.SQL.Add('DATEDIFF(day, Liefertag, getdate()) as Tage,Planned,PlannedLiefer schein,Pla nnedby,con vert(varch ar,cast(Pl annedDate as Date),104) as PlannedDate,PlannedFailed, ');
Qry.SQL.Add('Extern,c3.Nam e,c1.Owner ID,c1.Cons truction,c 4.Gestell as Email');
Qry.SQL.Add('from Ladelisten_GestellStammKop f c1');
Qry.SQL.Add('inner join LadeListen_GestellStammPos c2 on c1.ID=c2.HeadID');
Qry.SQL.Add('left join LadeListen_GestellEigentue mer c3 on c1.OwnerID=c3.ID');
Qry.SQL.Add('left join LadeListen_GestellKunden c4 on c2.Kuid=c4.HeadID');
Qry.SQL.Add('where MIX=1 and OutSide=1 and Planned=0 and Free=0');
Qry.SQL.Add('and Gestellname='+Gestellname+ ' and Kuid='+kuid+' and Gestell='+quotedstr(email) );
Qry.SQL.Add('order by DATEDIFF(day,Liefertag,get date()),Ge stellname asc');
Qry.Open;
if Qry.RecordCount <> 0 then
begin
// ************************** ** LOG ************************** ********** *
spWebLog.ConnectionString: ='FILE NAME='+ExtractFilePath(App lication.E xeName)+'\ teutodb.ud l';
spWebLog.CursorLocation := clUseServer;
spWebLog.Parameters.ParamV alues['@Ku id']:=strt oint(kuid) ;
spWebLog.Parameters.ParamV alues['@Ke mail']:=em ail;
spWebLog.Parameters.ParamV alues['@Ge stellname' ]:=gestell name;
spWebLog.Parameters.ParamV alues['@Cl ientIP']:= ARequestIn fo.RemoteI P;
spWebLog.Parameters.ParamV alues['@Cl ientURL']: =ARequestI nfo.URI;
spWebLog.Parameters.ParamV alues['@Cl ientAgent' ]:=AReques tInfo.User Agent;
spWebLog.Parameters.ParamV alues['@Ty pe']:=0;
spWebLog.Parameters.ParamV alues['@Re questDate' ]:=date+ti me;
spWebLog.ExecProc;
// ************************** ** LOG ************************** ********** *
AResponseInfo.ContentText := '<html><head><title>Transp ort XLR - Mini Webserver</title></head>' +
'<body>Sehr geehrte Kunde,' +
'<br />' +
'<br />' +
'<br />------------------------ ---------- ---------- ---------- ---------- ---------- ---------- ---' +
'<br /><b>Gestellname:</b> ' + gestellname +
'<br /><b>Kunde Nr.:</b> ' + kuid + ' ('+Qry.FieldByName('Kunde' ).Value+') ' +
'<br /><b>E-Mail:</b> ' + email +
'<br />------------------------ ---------- ---------- ---------- ---------- ---------- ---------- ---' +
'<br />' +
'<br />' +
'<br />Gestell '+gestellname+' Freigemeldet! Vielen Dank für Ihre Unterstützung! ' +
'<br />' +
'<br />' +
'<br />Mit Freudlichem Grüßen ' +
'<br />Transport XLR ' +
'<br />' +
'</body></html>';
// we mark the Rack free in our Database
spRack.ConnectionString:=' FILE NAME='+ExtractFilePath(App lication.E xeName)+'\ teutodb.ud l';
spRack.CursorLocation := clUseServer;
spRack.Parameters.ParamVal ues['@OP'] :='WEBMARK ';
spRack.Parameters.ParamVal ues['@Free ']:=1;
spRack.Parameters.ParamVal ues['@Free Date']:=da te+time;
spRack.Parameters.ParamVal ues['@Gest ellname']: =gestellna me;
spRack.ExecProc;
// we also insert an entry into the History of the Rack
spHist.ConnectionString:=' FILE NAME='+ExtractFilePath(App lication.E xeName)+'\ teutodb.ud l';
spHist.CursorLocation := clUseServer;
spHist.Parameters.ParamByN ame('@OP') .Value:='I NS';
spHist.Parameters.ParamByN ame('@Kuid ').Value:= strtoint(k uid);
spHist.Parameters.ParamByN ame('@Kund e').Value: =Qry.Field ByName('Ku nde').Valu e;
spHist.Parameters.ParamByN ame('@Adre sse').Valu e:=Qry.Fie ldByName(' Adresse'). Value;
spHist.Parameters.ParamByN ame('@Ort' ).Value:=Q ry.FieldBy Name('Ort' ).Value;
spHist.Parameters.ParamByN ame('@Plz' ).Value:=Q ry.FieldBy Name('Plz' ).Value;
spHist.Parameters.ParamByN ame('@Land ').Value:= Qry.FieldB yName('Lan d').Value;
spHist.Parameters.ParamByN ame('@Lief erschein') .Value:=Qr y.FieldByN ame('Liefe rschein'). Value;
spHist.Parameters.ParamByN ame('@LKW' ).Value:=' ';
spHist.Parameters.ParamByN ame('@OR_T OUR').Valu e:='';
spHist.Parameters.ParamByN ame('@Lief ertag').Va lue:='1899 -01-01';
spHist.Parameters.ParamByN ame('@Modi fier').Val ue:='[KUND E]';
spHist.Parameters.ParamByN ame('@Modi fyDate').V alue:=date +time;
spHist.Parameters.ParamByN ame('@gest ellname'). Value:=ges tellname;
spHist.Parameters.ParamByN ame('@Fehl ergrund'). Value:='';
spHist.Parameters.ParamByN ame('@Dire ction').Va lue:=0;
spHist.Parameters.ParamByN ame('@Plan nedFailed' ).Value:=0 ;
spHist.Parameters.ParamByN ame('@Rese t').Value: =0;
spHist.Parameters.ParamByN ame('@Cons truction') .Value:=0;
spHist.Parameters.ParamByN ame('@Comp uter').Val ue:='Trans port XLR Mini Webserver';
spHist.ExecProc
end
else
begin
// ************************** ** LOG ************************** ********** *
spWebLog.ConnectionString: ='FILE NAME='+ExtractFilePath(App lication.E xeName)+'\ teutodb.ud l';
spWebLog.CursorLocation := clUseServer;
spWebLog.Parameters.ParamV alues['@Ku id']:=strt oint(kuid) ;
spWebLog.Parameters.ParamV alues['@Ke mail']:=em ail;
spWebLog.Parameters.ParamV alues['@Ge stellname' ]:=gestell name;
spWebLog.Parameters.ParamV alues['@Cl ientIP']:= ARequestIn fo.RemoteI P;
spWebLog.Parameters.ParamV alues['@Cl ientURL']: =ARequestI nfo.URI;
spWebLog.Parameters.ParamV alues['@Cl ientAgent' ]:=AReques tInfo.User Agent;
spWebLog.Parameters.ParamV alues['@Ty pe']:=1;
spWebLog.Parameters.ParamV alues['@Re questDate' ]:=date+ti me;
spWebLog.ExecProc;
// ************************** ** LOG ************************** ********** *
AResponseInfo.ContentText := '<html><head><title>Transp ort XLR - Mini Webserver</title></head>' +
'<body>Sehr geehrte Kunde,' +
'<br />' +
'<br />' +
'<br />------------------------ ---------- ---------- ---------- ---------- ---------- ---------- ---' +
'<br />Die von Ihnen eingegebene Gestellnummer '+gestellname+' ist nicht länger Gültig ' +
'<br />Möglicheweise ist die Gestell von Ihnen abgeholt oder Sie haben es bereits Freigemeldet. ' +
'<br />Falls nicht bitte schreiben Sie ein e-mail an : gestelle@teutoglas.de ' +
'<br />------------------------ ---------- ---------- ---------- ---------- ---------- ---------- ---' +
'<br />' +
'<br />' +
'<br />Mit Freudlichem Grüßen ' +
'<br />Transport XLR ' +
'<br />' +
'</body></html>';
end;
finally
Qry.Free;
CoUninitialize();
end;
end
else
begin
// ************************** ** LOG ************************** ********** *
// ************************** ** LOG ************************** ********** *
AResponseInfo.ContentText := '<html><head><title>Transp ort XLR - Mini Webserver</title></head>' +
'<body>Sehr geehrte Kunde,' +
'<br />' +
'<br />' +
'<br />------------------------ ---------- ---------- ---------- ---------- ---------- ---------- ---' +
'<br /><b>Eingabe Fehler</b> ' +
'<br />------------------------ ---------- ---------- ---------- ---------- ---------- ---------- ---' +
'<br />' +
'<br />' +
'<br />Mit Freudlichem Grüßen ' +
'<br />Transport XLR ' +
'<br />' +
'</body></html>';
end;
end
else
begin
// ************************** ** LOG ************************** ********** *
// ************************** ** LOG ************************** ********** *
AResponseInfo.ContentText := '<html><head><title>Transp ort XLR - Mini Webserver</title></head>' +
'<body>Sehr geehrte Kunde,' +
'<br />' +
'<br />' +
'<br />------------------------ ---------- ---------- ---------- ---------- ---------- ---------- ---' +
'<br /><b>Eingabe Fehler</b> ' +
'<br />------------------------ ---------- ---------- ---------- ---------- ---------- ---------- ---' +
'<br />' +
'<br />' +
'<br />Mit Freudlichem Grüßen ' +
'<br />Transport XLR ' +
'<br />' +
'</body></html>';
end;
end;
Thank you but highly unlikely ... if I send the following url to the Webserver : http://192.168.88.46:666/
then the Static Webpage is executed. If I keep pressing the key for 30 minutes , did it just now. I still wont get an error .
The error comes from the AdoQuery , if I comment everything out and just leave the AdoQuery I get the error. Meanwhile I've altered the code a bit. I created the Query on the fly .
if inputstring.Count = 3 then
begin
// query and later stored procedures
end
else
begin
// shows static webpage
end;
Here the complete source again , altered :
procedure TMain.IdHTTPServer1Command
ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
var gestellname , kuid , email : string;
inputstring : TStringList;
temp : string;
// only used to check if kuid is valid
tempKuid , tempCode : integer;
// ado connection threaded
Qry : TADOQuery;
myConnect : TADOConnection;
begin
temp:=ARequestInfo.URI;
delete(temp,1,1);
inputstring := TStringList.Create;
inputstring.CommaText := temp;
if inputstring.Count = 3 then
begin
gestellname:=inputstring[0
kuid:=inputstring[1];
email:=inputstring[2];
inputstring.Free;
val(kuid,tempKuid,tempCode
if (length(gestellname) <= 50) and (length(kuid) <= 10) and (length(email) <= 50) and (tempCode = 0) then
begin
CoInitialize(nil);
Qry := TADOQuery.Create(nil);
try
Qry.ConnectionString:='FIL
Qry.CursorLocation:= clUseServer;
Qry.LockType := ltReadOnly;
if Qry.Active then Qry.Close;
Qry.SQL.Clear;
Qry.SQL.Add('select GestellName,Typ,Kuid,Kunde
Qry.SQL.Add('convert(varch
Qry.SQL.Add('DATEDIFF(day,
Qry.SQL.Add('Extern,c3.Nam
Qry.SQL.Add('from Ladelisten_GestellStammKop
Qry.SQL.Add('inner join LadeListen_GestellStammPos
Qry.SQL.Add('left join LadeListen_GestellEigentue
Qry.SQL.Add('left join LadeListen_GestellKunden c4 on c2.Kuid=c4.HeadID');
Qry.SQL.Add('where MIX=1 and OutSide=1 and Planned=0 and Free=0');
Qry.SQL.Add('and Gestellname='+Gestellname+
Qry.SQL.Add('order by DATEDIFF(day,Liefertag,get
Qry.Open;
if Qry.RecordCount <> 0 then
begin
// **************************
spWebLog.ConnectionString:
spWebLog.CursorLocation := clUseServer;
spWebLog.Parameters.ParamV
spWebLog.Parameters.ParamV
spWebLog.Parameters.ParamV
spWebLog.Parameters.ParamV
spWebLog.Parameters.ParamV
spWebLog.Parameters.ParamV
spWebLog.Parameters.ParamV
spWebLog.Parameters.ParamV
spWebLog.ExecProc;
// **************************
AResponseInfo.ContentText := '<html><head><title>Transp
'<body>Sehr geehrte Kunde,' +
'<br />' +
'<br />' +
'<br />------------------------
'<br /><b>Gestellname:</b> ' + gestellname +
'<br /><b>Kunde Nr.:</b> ' + kuid + ' ('+Qry.FieldByName('Kunde'
'<br /><b>E-Mail:</b> ' + email +
'<br />------------------------
'<br />' +
'<br />' +
'<br />Gestell '+gestellname+' Freigemeldet! Vielen Dank für Ihre Unterstützung! ' +
'<br />' +
'<br />' +
'<br />Mit Freudlichem Grüßen ' +
'<br />Transport XLR ' +
'<br />' +
'</body></html>';
// we mark the Rack free in our Database
spRack.ConnectionString:='
spRack.CursorLocation := clUseServer;
spRack.Parameters.ParamVal
spRack.Parameters.ParamVal
spRack.Parameters.ParamVal
spRack.Parameters.ParamVal
spRack.ExecProc;
// we also insert an entry into the History of the Rack
spHist.ConnectionString:='
spHist.CursorLocation := clUseServer;
spHist.Parameters.ParamByN
spHist.Parameters.ParamByN
spHist.Parameters.ParamByN
spHist.Parameters.ParamByN
spHist.Parameters.ParamByN
spHist.Parameters.ParamByN
spHist.Parameters.ParamByN
spHist.Parameters.ParamByN
spHist.Parameters.ParamByN
spHist.Parameters.ParamByN
spHist.Parameters.ParamByN
spHist.Parameters.ParamByN
spHist.Parameters.ParamByN
spHist.Parameters.ParamByN
spHist.Parameters.ParamByN
spHist.Parameters.ParamByN
spHist.Parameters.ParamByN
spHist.Parameters.ParamByN
spHist.Parameters.ParamByN
spHist.Parameters.ParamByN
spHist.ExecProc
end
else
begin
// **************************
spWebLog.ConnectionString:
spWebLog.CursorLocation := clUseServer;
spWebLog.Parameters.ParamV
spWebLog.Parameters.ParamV
spWebLog.Parameters.ParamV
spWebLog.Parameters.ParamV
spWebLog.Parameters.ParamV
spWebLog.Parameters.ParamV
spWebLog.Parameters.ParamV
spWebLog.Parameters.ParamV
spWebLog.ExecProc;
// **************************
AResponseInfo.ContentText := '<html><head><title>Transp
'<body>Sehr geehrte Kunde,' +
'<br />' +
'<br />' +
'<br />------------------------
'<br />Die von Ihnen eingegebene Gestellnummer '+gestellname+' ist nicht länger Gültig ' +
'<br />Möglicheweise ist die Gestell von Ihnen abgeholt oder Sie haben es bereits Freigemeldet. ' +
'<br />Falls nicht bitte schreiben Sie ein e-mail an : gestelle@teutoglas.de ' +
'<br />------------------------
'<br />' +
'<br />' +
'<br />Mit Freudlichem Grüßen ' +
'<br />Transport XLR ' +
'<br />' +
'</body></html>';
end;
finally
Qry.Free;
CoUninitialize();
end;
end
else
begin
// **************************
// **************************
AResponseInfo.ContentText := '<html><head><title>Transp
'<body>Sehr geehrte Kunde,' +
'<br />' +
'<br />' +
'<br />------------------------
'<br /><b>Eingabe Fehler</b> ' +
'<br />------------------------
'<br />' +
'<br />' +
'<br />Mit Freudlichem Grüßen ' +
'<br />Transport XLR ' +
'<br />' +
'</body></html>';
end;
end
else
begin
// **************************
// **************************
AResponseInfo.ContentText := '<html><head><title>Transp
'<body>Sehr geehrte Kunde,' +
'<br />' +
'<br />' +
'<br />------------------------
'<br /><b>Eingabe Fehler</b> ' +
'<br />------------------------
'<br />' +
'<br />' +
'<br />Mit Freudlichem Grüßen ' +
'<br />Transport XLR ' +
'<br />' +
'</body></html>';
end;
end;
ASKER
So update, now I am creating the adoconnection and the query on the fly...
I just tried a 5 min session (which till now was impossible without any errors) F5 on two computers pressed.
The website refreshed like crazy... no errors nowhere...
I commented out the stored procedures for testing....
SO it looks like the Query is finally ok like this...
I will probably need to dynamically create the stored procedure as well... or else it will not work.
I will report back later.
I just tried a 5 min session (which till now was impossible without any errors) F5 on two computers pressed.
The website refreshed like crazy... no errors nowhere...
I commented out the stored procedures for testing....
SO it looks like the Query is finally ok like this...
I will probably need to dynamically create the stored procedure as well... or else it will not work.
I will report back later.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
um ... you have a memory leak when inputstring.count <> 3
:)
:)
it would take a while until the memory leaks hits bottom (usually at 1.8gb memory usage if you compile in 32-bit)
process: boolean;
begin
process := false;
inputstring := TStringList.Create;
try
inputstring.CommaText := temp;
if inputstring.Count = 3 then
begin
process := true;
gestellname:=inputstring[0];
kuid:=inputstring[1];
email:=inputstring[2];
end;
finally
inputstring.Free;
end;
if process then
begin
// the rest
ASKER
Hard Work... Google ... Trial and Error
the return you get from EE: too many requests
have you ever seen a try finally construction ? this helps to avoid memory leaks in case of errors
Open in new window
i assume this is a built in mechanism in indy to prevent too many requests