Database creation problems

J

Jerry Spence1

I am creating a database as so:


Dim cat As New ADOX.Catalog()
Dim CurDB as String
Dim sCreateString As String

CurDB = "MyDatabase.mdb"
sCreateString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & CurDB
cat.Create(sCreateString)
cat = Nothing



The problem is that I wish to delete this database after copying it to
another folder. I can't because it says there is a sharing violation. It
also creates MyDatabase.ldb and this doesn't go even after I have set cat =
nothing. As soon as I stop my program, it frees it up and deletes the .ldb
file.

What do I have to do to close the database so I can delete it?

-Jerry
 
M

Miro

I have the same issue.

I have a procedure that creates an adox table and creates some fields and
indexes and then fully closes.

However Even if i go into windows explorer I cannot move the file till the
application is done.
I couldnt figure out what it was, so now i create the file in the proper
spot, and on next load, if it was a temp file i check
for these temp files and delete it out then.

Prior to exiting out hte first time i make sure the data file is empty.

Miro
 
R

RobinS

It probably has to do with garbage collection.
You may close all of your connections to the file,
but until the garbage collector releases all of them,
the file will still be locked. That's my guess.

Robin S.
 
J

Jerry Spence1

I've cracked it

Dim cat As Catalog = New Catalog()
Dim CurDB As String
CurDB = DestPath & "MyDatabase.mbd"

cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=5;Data
Source=" & CurDB)
cat.ActiveConnection.Close()
cat.ActiveConnection = Nothing
cat = Nothing


-Jerry
 

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