Database.DetachDatabase oddity

I have a Web app that connects to a MainDB on Session.Open (a sqlite db) and stays connected to that db until the Session closes. However, I have a method that attaches another sqlite db called OtherDB when the user calls a method that uses AttachDatabase:

MainDB.AttachDatabase("OtherDB", "other")

That attaches OtherDB to MainDB using an alias “other” so I can do a Join for some work. This method never writes to OtherDB. It has no problem doing the Join and getting some data over to MainDB. The Attach works fine. But I find that, even though the method in question eventually calls

MainDB.DetachDatabase("OtherDB")

with no errors, any subsequent attempt to call that method results in a db error:

"database other is already in use"

So it seems that the DetachDatabase method is not working. I have worked around this by closing and reconnecting MainDB, instead of using DetachDatabase. Is this a known problem with DetachDatabase? I don’t see anything about this in Feedback. If others say they have no problem with DetachDatabase, I’ll test this with a small Web db app to see if I can reproduce it that way.

If what you’ve written here is correct, you need to detach the alias. So it would be MainDB.DetachDatabase(“other”) instead of “OtherDB”.

Ah. I didn’t think of that! I’ll check tomorrow morning. Probably exactly what I was doing wrong. Thanks, Thom.

That was it, Thom. Thank!