Subject | Re: [firebird-support] Database file remains locked when connection is closed |
---|---|
Author | Hannes Streicher |
Post date | 2011-08-24T08:58:44Z |
Guten Tag psylencedave,
after disconection ( Sweep , garbage collection)
wait a while before trying to delete the file
--
Mit freundlichen GrĂ¼ssen
Hannes Streicher mailto:HStreicher@...
> 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?probably the file remains locked due to some internal housekeeping of the Database Engine going on
> 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
after disconection ( Sweep , garbage collection)
wait a while before trying to delete the file
--
Mit freundlichen GrĂ¼ssen
Hannes Streicher mailto:HStreicher@...