Quantcast
Channel: Embarcadero Community - Embarcadero Community
Viewing all articles
Browse latest Browse all 3212

Closing down FireDAC mulithreaded multi-database Access interface

$
0
0

I am trying to close all connections in a multi-threaded FireDAC system that interfaces to two separate MS Access 97 databases. After I have done this I then want to call the MS Access Compact function to "Compact" the MS Access database. This operation requires exclusive access to the database file, hence my reason for attempting to close all the connections.

I am using C++ Seattle 10 Subscription update 1. I am running on Windows 7 32 bit. The MSAccess database files on the local machine.

Here's my code:

// I aim to have all the connections set as Connected = false;  by the time this code is called.....

   for (int i = 0; i < FDManager()->ConnectionCount; i++) {

      FDManager()->Connections[i]->Connected = false;    // disconnect any that have been forgotten

   }

   FDManager()->DropConnections();

   FDManager()->CloseConnectionDef(Database1FireDACPooledConnectionDefName);  // these are string const used to define the two 

   FDManager()->CloseConnectionDef(DatabaseFireDACPooledConnectionDefName);   // pooled database connection definitions to the two databases

// should be no connections to the MS Access database files when I reach here

//--------------------------------------------------------------------------------------

When I run my code it works most of the time. At the end of these lines I can see that the MS Access *.ldb lock files have been deleted and my code is able to successfully call the FireDAC MS Access service "Compact" and successfully compact the database.

But then some times I get an exception and the *.ldb files remain - now I can't Compact. Worse, I don't know what to do to 

find the connection(s) that are causing the problem.

The exception I get is

++++++++++++++++++++++++++++++++++++++++++++++++++

[FireDAC][Phys]=334. FDPhysManager shutdown timeout. Possible

reason: application has not released all connection interfaces.

+++++++++++++++++++++++++++++++++++++++++++++++++

Strange thing is that once I get this error it seems to always give me this erroreach time I completely restart the application and try again. It's as if something in the MS Jet interface has locked me out. I don't know what I do to get it to work again - replacing the database  .mdb files with identical copies doesn't help. When my application is not running there is no *.ldb file present so I am sure that there is nothing else connecting to the database files. I have set all my design time connections in the IDE to Connected = false; to avoid the design time data units making connections. 

Any ideas of things to check would be appreciated !

Regards, Roger

 

 


Viewing all articles
Browse latest Browse all 3212

Trending Articles