Steve Gerrard wrote:
Mad Ape wrote:
>Steve Gerrard wrote:
>>The Mad Ape wrote:
When I use the code below to create an mdb (access database) I am
unable to release it and the locking file remains persistent. For my
app this is bad if the user tries to delete the mdb later on.
Has anyone encountered this scenario? Is this a bug? I am using
VB.Net 2005. Is there any way to get out of this jam? Currently my
app will only release its hold on the mdb after the app closes. I
do not understand.
Please help as I am on a deadline on Monday morning and am in a HUGE
pickle.
Dim catNewDB As New ADOX.Catalog
XMLFILE = strFi & "\merchantable" & strDate & strTime
catNewDB.Create("Provider=Microsoft.Jet.OLEDB.4 .0;" & "Data
Source=" & XMLFILE & ".mdb;")
catNewDB = Nothing
There is no member of ADOX to drop, close, destruct the connection.
Does catNewDB.Create(...) return the new database? If so, assigning
that to a variable might make closing the new database file easier.
If it does I do not know how to find it.
I have further code that opens it adds new tables and data then closes
it then disposes it but the .Create also creates a connection that I
can not release.
Just using the above code and nothing else creates a lock with no way
to remove it. I am stumped. Just to let you know I even tried:
System.Runtime.InteropServices.Marshal.ReleaseCom Object(catNewDB) but
that does not work either.
Very confused and frustrated.
The Mad Ape
catNewDB should have an ActiveConnection property. The doc says that if Create
succeeds, the connection to the newly created and opened database is assigned to
the catalog active connection. Using that, you should be able to close it.
The only thing I see is adding the line:
catNewDB.ActiveConnection = False
but that throws an error on the next line of code that is a simple
message box:
COMException was unhandled
'Arguments are of the wrong type, are out of acceptable range, or are in
conflict with one another'
System.Runtime.InteropServices.COMException was unhandled
ErrorCode=-2146825287
HelpLink="C:\WINDOWS\HELP\ADO270.CHM#1240641"
Message="Arguments are of the wrong type, are out of acceptable
range, or are in conflict with one another."
Source="ADOX.Catalog"
StackTrace:
at ADOX.CatalogClass.set_ActiveConnection(Object pVal)
I am totally perplexed here that something so simple is so complicated.
The Mad Ape