Home All Groups Group Topic Archive Search About

Database creation problems

Author
6 Nov 2006 5:01 AM
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

Author
6 Nov 2006 8:53 PM
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

Show quoteHide quote
"Jerry Spence1" <1@2.com> wrote in message
news:454ec1bb$0$8744$ed2619ec@ptn-nntp-reader02.plus.net...
>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
>
Author
7 Nov 2006 4:23 AM
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.

Show quoteHide quote
"Miro" <miron***@golden.net> wrote in message
news:uwcvkVeAHHA.4212@TK2MSFTNGP02.phx.gbl...
>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
>
> "Jerry Spence1" <1@2.com> wrote in message
> news:454ec1bb$0$8744$ed2619ec@ptn-nntp-reader02.plus.net...
>>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
>>
>
>
Author
10 Nov 2006 1:38 PM
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




Show quoteHide quote
"RobinS" <RobinS@NoSpam.yah.none> wrote in message
news:YPadneb8R4nFl83YnZ2dnUVZ_tydnZ2d@comcast.com...
> 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.
>
> "Miro" <miron***@golden.net> wrote in message
> news:uwcvkVeAHHA.4212@TK2MSFTNGP02.phx.gbl...
>>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
>>
>> "Jerry Spence1" <1@2.com> wrote in message
>> news:454ec1bb$0$8744$ed2619ec@ptn-nntp-reader02.plus.net...
>>>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
>>>
>>
>>
>
>
Author
13 Nov 2006 5:15 AM
Miro
So it seems to be the cat.activeconnection = nothing

Thanks!

M.

Show quoteHide quote
"Jerry Spence1" <jerry.spe***@somewhere.com> wrote in message
news:455480ce$0$8737$ed2619ec@ptn-nntp-reader02.plus.net...
> 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
>
>
>
>
> "RobinS" <RobinS@NoSpam.yah.none> wrote in message
> news:YPadneb8R4nFl83YnZ2dnUVZ_tydnZ2d@comcast.com...
>> 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.
>>
>> "Miro" <miron***@golden.net> wrote in message
>> news:uwcvkVeAHHA.4212@TK2MSFTNGP02.phx.gbl...
>>>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
>>>
>>> "Jerry Spence1" <1@2.com> wrote in message
>>> news:454ec1bb$0$8744$ed2619ec@ptn-nntp-reader02.plus.net...
>>>>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
>>>>
>>>
>>>
>>
>>
>
>