DLL and Database

DLL and Database

Post by Bernhard Weiger » Sun, 31 Dec 1899 09:00:00



Hello,
I want to use the same database connection in a DLL
like in the main application.

I tried to use a procedure with a TDatabase parameter
in the DLL, but I didn't manage to connect queries
with this TDatabase parameter.

Can anyone help
Thank you
Bernhard

 
 
 

DLL and Database

Post by M.H. Avegaar » Sun, 31 Dec 1899 09:00:00


Haven't tested it, but you could try:

DLLDatabase.Session := MasterDatabase.Session;



Quote:> Hello,
> I want to use the same database connection in a DLL
> like in the main application.

> I tried to use a procedure with a TDatabase parameter
> in the DLL, but I didn't manage to connect queries
> with this TDatabase parameter.

> Can anyone help
> Thank you
> Bernhard


 
 
 

DLL and Database

Post by Bernhard Weiger » Sun, 31 Dec 1899 09:00:00


Thank you,
but it didn't work!


Quote:>Haven't tested it, but you could try:

>DLLDatabase.Session := MasterDatabase.Session;

 
 
 

DLL and Database

Post by Whoeve » Sun, 31 Dec 1899 09:00:00


I had this code from an August 15, 1999 posting and have not tested it nor
verified accuracy.  May it will help with your problem.

"Just assign the handle to the database component"

Here is the part of the calling unit.

unit Calling_Unit;
interface
var MainDatabase: TDatabase;
implemention
uses Other_units, BDE; {you need BDE for type definition of HDBIDB}
function DLL_funtion(const hnd: HDBIDB): boolean; external 'YOURDLL.DLL';
procedure Calling_Proc;
var res: boolean;
begin
   res := DLL_funtion(MainDatabase.Handle); {MainDatabase must  be
connected}
end;

Note:  you can put the declaration of DLL_funtion in the interface part too,
then you have to include BDE in the uses clause of the interface

Here is the DLL

project file:
library YOURDLL
uses
  SysUtils,
  Classes,
  DLLMain in 'DLLMain.pas',

exports
  DLL_function index 1;
begin
end.

Unit file:
unit DLLMain;
interface
uses Other_Units,BDE;
var DLLDatabase: TDatabase;
function DLL_funtion(const hnd: HDBIDB):boolean;
implementation
function DLL_funtion(const hnd: HDBIDB): boolean;
begin
  DLLDataModule.DLLDatabase.Handle := hnd;
  {Now DLLDatabase uses the same connection as MainDatabase}
end;
end.

----- original message ------

Quote:> Hello,
> I want to use the same database connection in a DLL
> like in the main application.

> I tried to use a procedure with a TDatabase parameter
> in the DLL, but I didn't manage to connect queries
> with this TDatabase parameter.

> Can anyone help
> Thank you
> Bernhard

 
 
 

1. Accessing External API DLLs from Database

Hi There,

We are considering purchasing and integrating a Quick Address System for
verify addresses and returning barcodes for the address records that we have
stored in our 8.1.6.1 NT 4 Database.

We are thinking of using foreign package calls from within the database to
access their provided API DLL which was written in C++.

As I haven't implemented any foreign function calls before, I'm keen to know
if this is one of Oracles "Features" that never really worked, or whether it
is a reliable option that we can use.

Can anyone guide me and tell me how steep the learn curve is to getting
foreign functions up and running?  Is the database efficient at using
foreign function calls, or does it introduce memory leaks and instabilities?
How good is it at type conversions to and from the DLLs?

Thanks in advance,

Mike Cretan

2. Help for a rookie

3. Dlls and Databases

4. VB Code problem linking to SQL Server

5. Help with DLL and Database?

6. Deleting files in ObjectPal in Win 95

7. DLLs and Database Connecting

8. Question

9. Help required with dll to database

10. Any check point to build DLL using database access ?

11. DB2 7.2 DLL Load / Unload of DB2SYSP.DLL AND DB2KBC.DLL

12. Calling a public function in a VB ActiveX DLL from a VC DLL