🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.database.multi-tier
6 messages
6 total messages Started by Clayton M. Arends Sat, 06 Nov 1999 00:00
TDatabase shared in DLLs
#1382
Author: Clayton M. Arends
Date: Sat, 06 Nov 1999 00:00
20 lines
1366 bytes
Hello,

I have an application that has a few implicit DLLs and any number of
dynamically loaded DLLs.  One of the implicit DLLs (we'll call it DB.DLL)
takes care of my database connection.  The dynamically loaded DLL is called
after the database connection has been opened.  It also uses the DB.DLL.
When it attempts to call upon any methods in DB.DLL the database tries to
log in again.  Once logged in that DLL won't have to log in again.

I have KeepConnection set to true.  A show message reveals that the database
handles are the same in the main application and in the dynamic DLL.

My question is, how can I share the DLL database connection between DLLs and
my main application without having to log in again?  I also don't want to
have to manage multiple database connections.  I just want the one
connection.

Thanks,

Clayton
Re: TDatabase shared in DLLs
#1385
Author: Mark Cashman (TeamB BCB)
Date: Mon, 08 Nov 1999 00:00
23 lines
1413 bytes
Hi, Clayton!

I think you need to have the DLL have its own TSession. Have you done
that?

Also, the DLL must do ALL of the data management (the app will not have
the TSession or TDatabase needed).

Have you considered putting the database management in a run-time
package instead of a DLL?

Note that a DLL can also use the main app Application object in place of
its own. That can sometimes make things easier, though I am not an
expert on doing that or its implications.

------
Mark Cashman (TeamB - C++ Builder), creator of The Temporal Doorway at
http://www.temporaldoorway.com
- Original digital art, writing, music and more -
C++ Builder / JBuilder Tips and The C++ Builder Programmer's Webring
(Join us!)
http://www.temporaldoorway.com/programming/index.htm
------
Re: TDatabase shared in DLLs
#1386
Author: Mark Cashman (TeamB BCB)
Date: Mon, 08 Nov 1999 00:00
51 lines
2119 bytes
Hi, Clayton!

Each .exe definitely gets its own session (the default TSession
"Session"). Each thread must have a separate session. Since a DLL gets
its own application and the Session is Application based, I suspect this
means the same for the DLL. The exception, I believe is packages, where
all packages share the application object of the using application (I
think).

Good luck!

----


Clayton wrote:

I haven't tried using a session other than the default session yet.
Does
each EXE and DLL gets its own default session object then?

Yes, I plan on the DLL doing all the management.  I have several classes
and
objects that will return the items I need in TList's or TStringList's or

just plain record objects.

The dynamically loaded DLL has already been given the main executable's
TApplication object and is using it.  Does an implicitly loaded DLL have
a
different TApplication object?  (I guess I could write a little test to
see
if that's the case).

So I'll try setting all application objects the same and then create my
own
session object for the database DLL.

Thanks for the direction,

Clayton


--
------
Mark Cashman (TeamB - C++ Builder), creator of The Temporal Doorway at
http://www.temporaldoorway.com
- Original digital art, writing, music and more -
C++ Builder / JBuilder Tips and The C++ Builder Programmer's Webring
(Join us!)
http://www.temporaldoorway.com/programming/index.htm
------
Re: TDatabase shared in DLLs
#1387
Author: Jeff Overcash (TeamB)
Date: Mon, 08 Nov 1999 00:00
32 lines
1803 bytes

"Mark Cashman (TeamB BCB)" wrote:
> 
> Hi, Clayton!
> 
> Each .exe definitely gets its own session (the default TSession
> "Session"). Each thread must have a separate session. Since a DLL gets
> its own application and the Session is Application based, I suspect this
> means the same for the DLL. The exception, I believe is packages, where
> all packages share the application object of the using application (I
> think).
> 

Just to verify, yes with pacakges the Application is shared.  Beyond that all
the VCL global objects, like Session, Screens, Application etc are shared. 
Packages get mapped into the exe's address space, Dll's don't and there is a
'barrier' between your app and the Dll in terms of global VCL objects.  For VCL
objects using packages instead of Dlls will often solve a lot of synchronizing
problems with these global VCL objects.

> Good luck!
> 
> ----
> 

-- 
Jeff Overcash (TeamB) 
      (Please do not email me directly unless  asked. Thank You) 
Anyone who cannot cope with mathematics is not fully human.
At best he is a tolerable subhuman who has learned to wear 
shoes, bathe and not make messes in the house.   (Heinlein)
Re: TDatabase shared in DLLs
#1388
Author: Clayton M. Arends
Date: Mon, 08 Nov 1999 00:00
28 lines
1955 bytes
Okay, given the advice from Mark and Jeff I have decided that maybe a
package will be the best way to go about solving my problem.  However, the
only use I have of packages is in creating components.  I've never created a
package to be used for purposes like this.  (i.e. a replacement for a DLL).

When I tried I ran into several problems.  And I have several questions on
this matter.

1. I'm using the project manager to keep track of all my DLLs and EXEs and
such.  Is it possible to create a package that will only show up in the PM
or on a project by project basis rather than showing up in the "Package
Manager" (Component | Install Packages)?

2. I created a datamodule in the package.  Where and how should the data
module (or other form) get created?  In normal executables the creation
would happen in WinMain -- (i.e. CreateForm(__classid(TBlah), &Blah);

3. When I turned the option to "Build with runtime packages" on and added my
new package to the list the linker reported a "Unresolved external."  We all
know what that means.  How do I actually use the package correctly?

I guess what I'm trying to say here is ... HELP!  Do you have any good URLs
or examples in the help system that I can go to to find out how to use
packages correctly?  I'm getting desperate.

Thanks again,

Clayton
Re: TDatabase shared in DLLs
#1405
Author: Jeff Overcash (TeamB)
Date: Sun, 14 Nov 1999 00:00
59 lines
3024 bytes

"Clayton M. Arends" wrote:
> 
> Okay, given the advice from Mark and Jeff I have decided that maybe a
> package will be the best way to go about solving my problem.  However, the
> only use I have of packages is in creating components.  I've never created a
> package to be used for purposes like this.  (i.e. a replacement for a DLL).
> 
> When I tried I ran into several problems.  And I have several questions on
> this matter.
> 
> 1. I'm using the project manager to keep track of all my DLLs and EXEs and
> such.  Is it possible to create a package that will only show up in the PM
> or on a project by project basis rather than showing up in the "Package
> Manager" (Component | Install Packages)?
> 

You can add packages to a project group, but whenever you activate that pacakge
to work on you will get the Package Editor to work on it.

> 2. I created a datamodule in the package.  Where and how should the data
> module (or other form) get created?  In normal executables the creation
> would happen in WinMain -- (i.e. CreateForm(__classid(TBlah), &Blah);
> 

You can do this bacsically at any stage.  If you are using an import library
(which I recommend) to tie the packageto your main project then it is loaded
early and will be available to you in your WinMain function.

> 3. When I turned the option to "Build with runtime packages" on and added my
> new package to the list the linker reported a "Unresolved external."  We all
> know what that means.  How do I actually use the package correctly?
> 

You need to add the PACKAGE macro to your class declaration like

class PACKAGE TChildInPackage : public TForm
{...};

> I guess what I'm trying to say here is ... HELP!  Do you have any good URLs
> or examples in the help system that I can go to to find out how to use
> packages correctly?  I'm getting desperate.
> 

Sorry I didn't respond quicker on this, I didn't have the time until this
morning to throw together a little sample program.  If you want it e-mail me and
I'll send it to you.

> Thanks again,
> 
> Clayton

-- 
Jeff Overcash (TeamB) 
      (Please do not email me directly unless  asked. Thank You) 
Anyone who cannot cope with mathematics is not fully human.
At best he is a tolerable subhuman who has learned to wear 
shoes, bathe and not make messes in the house.   (Heinlein)
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads