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.

Reply via email to