You are not logged in.
Hi,
I'm getting an EAssertionFailed: "You should call TOleDBConnection.Free from the same thread which....". As it's stated on the documentation, I've implemented the OnHttpThreadTerminate event:
HttpServer.OnHttpThreadTerminate := FOnThreadTerminate;
then,
procedure THTTPTerminals.FOnThreadTerminate(sender: TThread);
begin
FDBMain.ConProp.EndCurrentThread;
FDBProd.ConProp.EndCurrentThread;
end
the strange behaviour is that if I call the server, it works without any trouble, but, if I left the server running without making any call for some time, then, the first call after that pause throws that assertion, and subsecuents calls works without throwing that assertion.
probably I should say that I've to extend a legacy system which has two databases. I know that this isn't an ideal situation, but, it what i have. So, i'm using two connections, each one with his own model.
Thanks
Last edited by cregonat (2020-06-28 15:29:33)
Offline
It could be that DB itself or OLE terminates connection after inactivity and then when you try to call it it raises exception and next one get's a new connection established.
You can try to configure ConnectionTimeOutMinutes on your OleDB connection properties.
Offline
How is ConProp defined? Is it a property?
If it is a local variable, then the connection may have been freed in-between so the instance stored in your variable is invalid.
Please don't store the connection instance, but retrieve it in the beginning of each method using TSQLDBConnectionProperties.ThreadSafeConnection, or by using TSQLDBConnectionProperties.NewThreadSafeStatement/NewThreadSafeStatementPrepared.
Offline