Database is currently in use by you or another user: database.nsf

Hi… I have the following code in user run agent which creates a number of databases based on a template. The newly created databases when tried to be deleted give the error msg “Database is currently in use by you or another user: filename.nsf”. Filename.nsf is the name of the created database. If I exit and re-enter Notes they can be deleted.

I’m assuming the agent that is creating them is keeping the database open. How I can force the database closed ?

Suggestions?

Dim workspace As New NotesUIWorkspace

Dim template As New NotesDatabase( “”, “template.ntf” )

Dim brandNewDb As NotesDatabase

Dim i as Integer

for i = 1 to 16

Set brandNewDb = template.CreateFromTemplate ( “”, “filename” & i & “.nsf”, True )

brandNewDb.Title = "Title " & i

Call brandNewDb.GrantAccess(“-Default-”, 6)

brandNewDb.DelayUpdates = False

Call workspace.AddDatabase ( “”, “filename” & i & “.nsf” )

Call workspace.ReloadWindow( )

set brandNewDb = nothing

next i

Thanks, James

Subject: Database is currently in use by you or another user: database.nsf

To be sure that you don’t use the DB any longer, try Delete brandNewDb

instead of

set brandNewDb = nothing

The method Delete do not delete the database (LOL) but it will completely clear the brandNewDb object from memory.

Either that, or maybe the database, after creating, gets some attention from the server side, like reindexing. In that case, you cannot do much.

Good luck.

Darina

Subject: RE: Database is currently in use by you or another user: database.nsf

That did the TRICK ! Thanks so much ! ( funny thing is I have Delete statements in other parts of the same code… )

James