Hi there,
I have upgraded an old project that worked perfectly well with XP/D2009/ODAC6 which creates reports, each report are launched with the use of a separate DLL for each report.
Unfortunately, since a simple upgrade to W7/DelphiXE/ODAC 7 & 8, I am not able to make it work anymore?!
The query always works fine the first time it is launched but I get violation errors or process hanging after several times?!
It seems that ODAC 7&8 does not properly frees some resources when executed inside a DLL??? (That same query works perfectly fine in a standard compiled exe file!)
I have created a very basic project w/a DLL to show you the trouble: https://www.br-e-a-s-t.org/uploads/DebugODAC.zip
Please help, I have lost days with that problem...
Huge thanks,
ODAC and DLL not working?
-
Kaus Media
- Posts: 13
- Joined: Tue 12 Sep 2006 10:02
Weird solution !?!?!? Definitely some ODAC bug...
Don't ask me why... But inside a DLL, this one works fine:
Var fDatabase: TOraSession;
Var sqlQuery: TOraQuery;
procedure Create (Database: TOraSession); stdcall;
begin
fDatabase := Database;
sqlQuery := TOraQuery.Create(Nil);
sqlQuery.Session := fDatabase;
end;
procedure Destroy; stdcall;
begin
sqlQuery.Free;
end;
procedure Query (strQuery: string); stdcall;
begin
sqlQuery.SQL.Text := strQuery;
sqlQuery.Open;
sqlQuery.Close;
end;
exports Create, Destroy, Query;
And this one doesn't
(Produce unending loop on the second call to the query):
Var fDatabase: TOraSession;
procedure Create (Database: TOraSession); stdcall;
begin fDatabase := Database; end;
procedure Query (strQuery: string); stdcall;
Var sqlQuery: TOraQuery;
begin
sqlQuery := TOraQuery.Create(Nil);
sqlQuery.Session := fClinical;
sqlQuery.SQL.Text := strQuery;
sqlQuery.Open;
sqlQuery.Close;
sqlQuery.Free;
end;
exports Create, Query;
Well, now at least I have a solution to make this damn code work...
Var fDatabase: TOraSession;
Var sqlQuery: TOraQuery;
procedure Create (Database: TOraSession); stdcall;
begin
fDatabase := Database;
sqlQuery := TOraQuery.Create(Nil);
sqlQuery.Session := fDatabase;
end;
procedure Destroy; stdcall;
begin
sqlQuery.Free;
end;
procedure Query (strQuery: string); stdcall;
begin
sqlQuery.SQL.Text := strQuery;
sqlQuery.Open;
sqlQuery.Close;
end;
exports Create, Destroy, Query;
And this one doesn't
(Produce unending loop on the second call to the query):
Var fDatabase: TOraSession;
procedure Create (Database: TOraSession); stdcall;
begin fDatabase := Database; end;
procedure Query (strQuery: string); stdcall;
Var sqlQuery: TOraQuery;
begin
sqlQuery := TOraQuery.Create(Nil);
sqlQuery.Session := fClinical;
sqlQuery.SQL.Text := strQuery;
sqlQuery.Open;
sqlQuery.Close;
sqlQuery.Free;
end;
exports Create, Query;
Well, now at least I have a solution to make this damn code work...
Hello,
As I've written you earlier, the problem does not occur even if the local variable is used. Maybe adding the try..finally block will help you:
Var sqlQuery: TOraQuery;
begin
sqlQuery := TOraQuery.Create(Nil);
sqlQuery.Session := fClinical;
sqlQuery.SQL.Text := strQuery;
try
sqlQuery.Open;
sqlQuery.Close;
finally
sqlQuery.Free;
end;
As I've written you earlier, the problem does not occur even if the local variable is used. Maybe adding the try..finally block will help you:
Var sqlQuery: TOraQuery;
begin
sqlQuery := TOraQuery.Create(Nil);
sqlQuery.Session := fClinical;
sqlQuery.SQL.Text := strQuery;
try
sqlQuery.Open;
sqlQuery.Close;
finally
sqlQuery.Free;
end;
-
Kaus Media
- Posts: 13
- Joined: Tue 12 Sep 2006 10:02
??? Solved...
I have created a virtual XP machine and reinstalled all the software (XE, ODAC 8.1) and everything works.
It seems then it is related to my Delphi/Odac installation (x32/x64 or file versioning trouble...). Strange, but at least I can compile properly now...
Thanks anyway for your help...
It seems then it is related to my Delphi/Odac installation (x32/x64 or file versioning trouble...). Strange, but at least I can compile properly now...
Thanks anyway for your help...