Have I found a bug in VB.Net 2005 ADOX.Catalog?

  • Thread starter Thread starter The Mad Ape
  • Start date Start date
T

The Mad Ape

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.

Thanks for any help you can provide.

Peace

The Mad Ape
 
Steve said:
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.ReleaseComObject(catNewDB) but
that does not work either.

Very confused and frustrated.

The Mad Ape
 
Steve said:
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
 
Steve said:
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 linecatNewDB.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
 
Steve said:
I don't believe it meant that ActiveConnection was a boolean indicating whether
it was active or not.

ActiveConnection is a reference to the Connection object that created and opened
the database.

I would expect a call similar to

catNewDB.ActiveConnection.Close()

perhaps preceded by a check to see if ActiveConnection was not Nothing.

Ahhh .close is a member but it does not show up in the list of members
on my box. There must be a gremlin in my version of VB.Net that fails to
list all of the members available to me. Is there anyway you could
verify whether it is just on my box or is this an omission on
Microsoft's part.

The only reason I ask is that there may be more members missing.

Anyway I have it working now and can relax and have a beer. Thanks for
the help. This bugaboo was driving me crazy all day.

The Mad Ape
 
Back
Top