Board index » delphi » Delphi 2.0 DLL with MS SQL 6.5

Delphi 2.0 DLL with MS SQL 6.5

Hi,

I have a mostly C++ written program that loads and makes calls to a
Delphi 2.0 DLL. Inside the Delphi DLL, I initialize a TDatabase
Component and connect it to the same database that the C++ program is
connected to (through a home-brewed configuration file). This method has
works fine when the database that the program connects to is an MS
Access database. However, when I configure the program to connect to an
SQL Server, the Program itself, and more likely, the Delphi DLL will
crash upon exiting. I change the code in the Delphi DLL so that it does
NOT initialize the database, but it still creates the TDatabase
component, and when I exit the program, it seems to be ok. The program
crashes ONLY when I connect the TDatabase component (using db.connect :=
true) AND when it connects to SQL Server. I am thinking of several
things: 1) could it be a session problem? My TDatabase is set up to
connect to the Default session. 2) could it be a problem with threads?
Perhaps the database is calling a DbiExit BEFORE the TDatabase component
is properly cleaned up and 3) when I re-compile the SAME code to run as
an executable (adding a form to display for visual sake), the delphi DLL
(now an executable) will run and exit properly. It's only the DLL
version of my code that crashes.

Any help is appreciated

 

Re:Delphi 2.0 DLL with MS SQL 6.5


Quote
DTI wrote:

> Hi,

> I have a mostly C++ written program that loads and makes calls to a
> Delphi 2.0 DLL. Inside the Delphi DLL, I initialize a TDatabase
> Component and connect it to the same database that the C++ program is
> connected to (through a home-brewed configuration file). This method has
> works fine when the database that the program connects to is an MS
> Access database. However, when I configure the program to connect to an
> SQL Server, the Program itself, and more likely, the Delphi DLL will
> crash upon exiting. I change the code in the Delphi DLL so that it does
> NOT initialize the database, but it still creates the TDatabase
> component, and when I exit the program, it seems to be ok. The program
> crashes ONLY when I connect the TDatabase component (using db.connect :=
> true) AND when it connects to SQL Server. I am thinking of several
> things: 1) could it be a session problem? My TDatabase is set up to
> connect to the Default session. 2) could it be a problem with threads?
> Perhaps the database is calling a DbiExit BEFORE the TDatabase component
> is properly cleaned up and 3) when I re-compile the SAME code to run as
> an executable (adding a form to display for visual sake), the delphi DLL
> (now an executable) will run and exit properly. It's only the DLL
> version of my code that crashes.

> Any help is appreciated

Hello,
  try linking in DBTables.pas and make sure that DbiDLLExit is being
called in that unit.

  Scott
--
BDE Support:
 http://www.inprise.com/devsupport/bde
Delphi Support:
 http://www.inprise.com/devsupport/delphi
Common Delphi and BDE Questions and Answers:
 http://www.inprise.com/devsupport/delphi/qanda/

Other Threads