Board index » delphi » Shared database connection in DLLs

Shared database connection in DLLs

Hi all.

Can anybody help me to solve how to share database connection in a DLLs. At
run-time and design time.

In run-time i have this shared database connection in my DLL by passing a
TDatabase's handle from the executable to the DLL.
Can package with my TDataModule can solve problem at design-time?

Vladislav Shulgin

 

Re:Shared database connection in DLLs


Hi,
    At run time you can have a dll that establishes the database connection
and let all other dlls access the database from the same dll. In this case
you can get the database handle from the dll where database connection is
established. U can use TDatamodule for the same but in client end have one
more database component where u can assign the database handle from the
database in the dll. and let all ur queries and table components in the
other dll refer to the database component within the same dll. you can
manipulate the same things in all the dlls. It actually solves the problem
when u need to use the same database handle for multiple dlls.
    Hope this helps.
--
---------------------------------------------------
Samir Kumar Mishra
Icode Inc.
-- Solutions with Software --
sam...@icode.com
---------------------------------------------------
Quote
Vladislav Shulgin <shu...@yam.com.ua> wrote in message

news:87m863$i8a$1@linux.mers.com...
Quote
> Hi all.

> Can anybody help me to solve how to share database connection in a DLLs.
At
> run-time and design time.

> In run-time i have this shared database connection in my DLL by passing a
> TDatabase's handle from the executable to the DLL.
> Can package with my TDataModule can solve problem at design-time?

> Vladislav Shulgin

Re:Shared database connection in DLLs


Hi Vladislav!

Quote
>Can anybody help me to solve how to share database connection in a DLLs. At
>run-time and design time.

>In run-time i have this shared database connection in my DLL by passing a
>TDatabase's handle from the executable to the DLL.
>Can package with my TDataModule can solve problem at design-time?

Yes. You can create run/design time package that include TDataModule
descendant with TDatabase component so this component will be alive
both in run and design time. Further, you can fix that TDatabase to
point to some predefined BDE alias that exists only in design and then
in run time use drivername instead of alias name to define real path
to database.

Also you don't have to use database handle, you can just use
databasename because when your TDatabase component is alive (created)
then automaticaly all TQuery, TTable and TStoredProc from your process
can access it through databasename property. You don't actualy need a
new TDatabase component.

tomi.

Re:Shared database connection in DLLs


What would be a correct or common way to share database connection between
two or more applications, not dll?

Johnny

Re:Shared database connection in DLLs


Just my Luck - I want to Share a database connection between my .EXE and a
.DLL but I want the TDatabase to be maintained in the .EXE

can anyone give me and example of how to do this?

Regards

Colin Dawson
cdaw...@ftm-tyrefit.co.uk

Other Threads