Subject Re: [firebird-support] Database file remains locked when connection is closed
Author "Ing. Patrick Frießnegg"
Hello,
if you use Classic Server have a look on your Taskmanager. Each
connection creates an instance of fb_inet_server.exe. As long as this
process exists, you can't modify the file. This is only true for classic
server (but maybe it's helpful to test)!

At first look, i would say that the connection-pooling of .NET Provider
is enabled (by default). Therefore, the .Close() command does not really
disconnect from the file. It just put the opened connection back to the
pool. Try to add

cs.Pooling = false;


to your Connection-String.
Be aware: connection pooling is not a bad thing for a production system.
But it's maybe the problem in your test.


Mit freundlichen Grüßen
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

*Ing. Frießnegg Patrick*
Software Development
Playmonitor Vertriebs-GmbH

Dechant-Thaller-Str. 37
II. Stock
A-8430 Leibnitz

T.: -
F.: +43 (0) 3452 71082
M.: p.friessnegg@...

OpenPGP: subkeys.pgp.net
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


Am 24.08.2011 10:09, schrieb psylencedave:
>
>
> I have the following code to create a database in C#, but the
> application doesn't release the database file when the connection is
> closed. What am I doing wrong?
>
> public class FirebirdDatabase
> {
> FbConnection connection;
>
> public void CreateDatabase()
> {
> try
> {
> FbConnectionStringBuilder cs = new FbConnectionStringBuilder();
> cs.Database = "C:\TestDb.GDB";
> cs.UserID = "SYSDBA";
> cs.Password = "masterkey";
>
> FbConnection.CreateDatabase(cs.ToString(), true);
> this.connection = new FbConnection(cs.ToString());
> this.connection.Open();
> this.connection.Close(); //doesn't release DB file
> this.connection.Dispose(); //doesn't release DB file
> File.Delete(cs.Database); //fails here!
> }
> catch
> {
> }
> }
> }
>
> Full error message:
>
> Code:
> The process cannot access the file 'C:\TestDb.GDB' because it is being
> used by another process
>
> Why is it still locked?
>
> I'm using the latest releases:
>
> - FirebirdSql.Data.FirebirdClient.dll v2.6.0.0
> - Firebird Server v2.5.0.26074
>
> I posted this problem on another board but got no response. I am
> completely stuck! Please help.
>
>


[Non-text portions of this message have been removed]