From: Mark R. <ma...@la...> - 2014-06-27 16:27:11
|
On 27-6-2014 18:09, Scott Morgan wrote: > Trying to drop a DB opened with the embedded system, but something seems > to be holding the file open after the connection is closed. > > Test case from a console app: > > Console.WriteLine("Attempting to open DB..."); > var conn = new FbConnection(); > conn.ConnectionString = myConnectionString; > conn.Open(); > > Console.WriteLine("Attempting to close DB..."); > conn.Close(); > > conn = null; > GC.Collect(); // Getting desperate here > > Console.WriteLine("Attempting to delete DB..."); > FbConnection.DropDatabase(ConnectionString); > // File.Delete(DBPath); // doesn't work either The .net provider has a connection pool, so the physical connection is still open. You need to flush the pool, or disable connection pooling. You can flush the pool with: FbConnection.ClearAllPools(); and disable connection pooling by setting Pooling=false in the connection string. Mark -- Mark Rotteveel |