LockFile Exist after create Access Database

  • Thread starter hui mc via .NET 247
  • Start date
H

hui mc via .NET 247

Hi All,
I have a problem after created the access database
the following is my code

private void CreateDatabase()
{
File.Delete(ExportFileDest);
ADOX.Catalog cat = new ADOX.CatalogClass();
cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\DailyAttendance.mdb;" +
"Jet OLEDB:EngineType=5");
cat = null;
}

it is fine for first time to create the database but fail if execute twice when the code try to delete
the existing file.
the access file is lock after the first creation. it only release until i closed the application program.
i don't understand why "cat = null;" cannot release the file.
is anyone can help me on this problem? thanks a lot.





From: hui mc
 
C

Cowboy \(Gregory A. Beamer\)

I do not work with Office objects, but see if there is a Dispose method on
the .NET wrapper, as that is a major contention. You have to make sure you
close everything and dispose of objects when using Interop.

For DB creation, I prefer having a raw .mdb and simply copying for the
creation process. I can then use SQL for everything else and not worry about
using the Office objects on my web server and risking a security hole.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think outside the box!
*************************************************
 
P

Paul Clement

¤ Hi All,
¤ I have a problem after created the access database
¤ the following is my code
¤
¤ private void CreateDatabase()
¤ {
¤ File.Delete(ExportFileDest);
¤ ADOX.Catalog cat = new ADOX.CatalogClass();
¤ cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\DailyAttendance.mdb;" +
¤ "Jet OLEDB:EngineType=5");
¤ cat = null;
¤ }
¤
¤ it is fine for first time to create the database but fail if execute twice when the code try to delete
¤ the existing file.
¤ the access file is lock after the first creation. it only release until i closed the application program.
¤ i don't understand why "cat = null;" cannot release the file.
¤ is anyone can help me on this problem? thanks a lot.
¤

Try closing the connection using the ActiveConnection property and then set it to Nothing (or null).


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
G

Guest

Hi All,
I have a problem after created the access database
the following is my code
{
File.Delete(ExportFileDest);
ADOX.Catalog cat = new ADOX.CatalogClass();
cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\DailyAttendance.mdb;" +
"Jet OLEDB:EngineType=5");
cat = null;
}
the existing file.
the access file is lock after the first creation. it only release until i closed the application program.
i don't understand why "cat = null;" cannot release the file.
is anyone can help me on this problem? thanks a lot.
Posted by a user from .NET 247 (http://www.dotnet247.com/)

User submitted from AEWNET (http://www.aewnet.com/)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top