Discussion:
Share ADO Connection from Exe TO DLL
(too old to reply)
PlutuDev
2004-09-15 15:41:08 UTC
Permalink
I built my application with many dll (for reporting)

but when i load dll, I reconnect TAdoConnection.. I want to avoid this
reconnection.. but how to do this ??.

I have try passing ADOConnectionObject :_Connection from exe to dll
so when i load dll,
i write dm.dbCon.ConnectionObject := AdoCon;

dm -> datamodule
dbcon -> TADOConnection
adoCon -> _Connection

it's succesfully. but after exit from dll, back to exe..
my connection is lost cause of FreeLibrary(dlllib)

How to fix this problem..
or is there other solution

Sorry for bad eglish

thanks in advance
Andrew
2004-09-18 00:53:26 UTC
Permalink
Post by PlutuDev
I built my application with many dll (for reporting)
but when i load dll, I reconnect TAdoConnection.. I want to avoid this
reconnection.. but how to do this ??.
I have try passing ADOConnectionObject :_Connection from exe to dll
so when i load dll,
i write dm.dbCon.ConnectionObject := AdoCon;
dm -> datamodule
dbcon -> TADOConnection
adoCon -> _Connection
it's succesfully. but after exit from dll, back to exe..
my connection is lost cause of FreeLibrary(dlllib)
I suggest that you set dm.dbCon.ConnectionObject := nil before calling
FreeLibrary.

HTH
Andrew
PlutuDev
2004-09-21 15:35:56 UTC
Permalink
I have try your suggestion.. ADOConnection still lost. any solution or
have other solution to passing ado connection????,
so in my dll not reconnect database
PlutoDev
Post by Andrew
Post by PlutuDev
I built my application with many dll (for reporting)
but when i load dll, I reconnect TAdoConnection.. I want to avoid this
reconnection.. but how to do this ??.
I have try passing ADOConnectionObject :_Connection from exe to dll
so when i load dll,
i write dm.dbCon.ConnectionObject := AdoCon;
dm -> datamodule
dbcon -> TADOConnection
adoCon -> _Connection
it's succesfully. but after exit from dll, back to exe..
my connection is lost cause of FreeLibrary(dlllib)
I suggest that you set dm.dbCon.ConnectionObject := nil before calling
FreeLibrary.
HTH
Andrew
PlutuDev
2004-09-21 15:37:30 UTC
Permalink
for example where i can email my code sample ??
Post by PlutuDev
I have try your suggestion.. ADOConnection still lost. any solution or
have other solution to passing ado connection????,
so in my dll not reconnect database
PlutoDev
Post by Andrew
Post by PlutuDev
I built my application with many dll (for reporting)
but when i load dll, I reconnect TAdoConnection.. I want to avoid this
reconnection.. but how to do this ??.
I have try passing ADOConnectionObject :_Connection from exe to dll
so when i load dll,
i write dm.dbCon.ConnectionObject := AdoCon;
dm -> datamodule
dbcon -> TADOConnection
adoCon -> _Connection
it's succesfully. but after exit from dll, back to exe..
my connection is lost cause of FreeLibrary(dlllib)
I suggest that you set dm.dbCon.ConnectionObject := nil before calling
FreeLibrary.
HTH
Andrew
hu zhenghui
2004-11-09 17:30:11 UTC
Permalink
The code below works:
//////////////////////////////////////////////////
procedure Test(ADOConnection : TADOConnection); external 'ProjectDll.dll';

procedure TFormExe.ButtonDllClick(Sender: TObject);
begin
Test(ADOConnection);
end;
//////////////////////////////////////////////////
library ProjectDll;

uses
ADODB,
Dialogs,
Classes,
SysUtils;

{$R *.res}

procedure Test(ADOConnection : TADOConnection);
begin
ShowMessage(BoolToStr(ADOConnection.Connected, true));
end;

exports Test;

begin
end.
--
If my answer can't solve you problem, welcome mail me the project files.
Post by PlutuDev
for example where i can email my code sample ??
Post by PlutuDev
I have try your suggestion.. ADOConnection still lost. any solution or
have other solution to passing ado connection????,
so in my dll not reconnect database
PlutoDev
Post by Andrew
Post by PlutuDev
I built my application with many dll (for reporting)
but when i load dll, I reconnect TAdoConnection.. I want to avoid this
reconnection.. but how to do this ??.
I have try passing ADOConnectionObject :_Connection from exe to dll
so when i load dll,
i write dm.dbCon.ConnectionObject := AdoCon;
dm -> datamodule
dbcon -> TADOConnection
adoCon -> _Connection
it's succesfully. but after exit from dll, back to exe..
my connection is lost cause of FreeLibrary(dlllib)
I suggest that you set dm.dbCon.ConnectionObject := nil before calling
FreeLibrary.
HTH
Andrew
Mike Shkolnik
2004-11-09 19:05:53 UTC
Permalink
...
This is an incorrect solution. If you'll compile your exe and dll in
different Delphi versions you'll see that your code will fail

PS: as hint - TADOConnection in exe and TADOConnection in dll are different
classes
--
With best regards, Mike Shkolnik
E-mail: ***@scalabium.com
WEB: http://www.scalabium.com
hu zhenghui
2004-11-18 08:51:19 UTC
Permalink
However, my code works well in my application.
Before you provide a better solution, your answer can not help PlutuDev.
--
If my answer can't solve you problem, welcome mail me the project files.
Post by Mike Shkolnik
...
This is an incorrect solution. If you'll compile your exe and dll in
different Delphi versions you'll see that your code will fail
PS: as hint - TADOConnection in exe and TADOConnection in dll are different
classes
--
With best regards, Mike Shkolnik
WEB: http://www.scalabium.com
Arthur Hoornweg
2004-11-03 14:56:46 UTC
Permalink
IIRC, there's a property for this (tadoconnection.keepconnection)
that you must set to true in both components.
--
Arthur Hoornweg
(please remove the ".net" from my e-mail address.
I had to take this measure to counteract SPAM
flooding my mail box)
hu zhenghui
2004-09-21 22:28:42 UTC
Permalink
_Connection is Interface, it has "reference counting", Why not passing the
TADOConnection?
--
If my answer can't solve you problem, welcome mail me the project files.
Post by PlutuDev
I built my application with many dll (for reporting)
but when i load dll, I reconnect TAdoConnection.. I want to avoid this
reconnection.. but how to do this ??.
I have try passing ADOConnectionObject :_Connection from exe to dll
so when i load dll,
i write dm.dbCon.ConnectionObject := AdoCon;
dm -> datamodule
dbcon -> TADOConnection
adoCon -> _Connection
it's succesfully. but after exit from dll, back to exe..
my connection is lost cause of FreeLibrary(dlllib)
How to fix this problem..
or is there other solution
Sorry for bad eglish
thanks in advance
Continue reading on narkive:
Search results for 'Share ADO Connection from Exe TO DLL' (Questions and Answers)
5
replies
can i get question answer of asp.net ?
started 2006-10-11 00:02:47 UTC
software
Loading...