Domino web server: Specified database is not currently open

I am moving attachments from one database to another using the following code in the web query save event. This code executes with out any error all time. But when saving the document into domino database, Lotus domino fails to save the document, logs and returns the following error message. This error occurs approx. 2% of times. Let me know if any one of you have any idea to find out source of the problem.

Code:

Sub InsertLB01(db As NotesDatabase, doc As notesdocument)

	'Gets a handle to selected documents and processes them



On Error Goto ErrorHandler

Dim cDoc					As notesDocument	

Dim LBdb 					As notesDatabase

Dim LBdoc 					As notesdocument

Dim doc2					As notesdocument	

Dim vw 						As NotesView

Dim cdocID 				As String

Dim LBDocID				As String

Dim lbdbpath 				As String

Dim ItemBodyText			As String

Dim i							As Integer

Dim RTItemLB01 			As Variant

Dim RTItemDoc 			As Variant



addtolog "InsertLB01 started."



Set vw 						= db.getview("vw-keys")

Set doc2 					= vw.getdocumentbykey("Database_HostFileReceiver")

lbdbpath						= doc2.valueED(0)

addtolog lbdbpath

Set LBdb					= New NotesDatabase(db.server, lbdbpath)

If (Not LBdb.isOpen()) Then

	If LBdb.open(db.server,lbdbpath) Then

		'do nothing

	Else

		dblogReport.LogTitle = "Error Insert LB01 -->" + doc.Doc_Title(0)

		AddToLog("Host file reciver database is not able to open..")

		AddToLog("close  the  agent return error")

		Print "<script type='text/javascript'>alert ('Error while inserting LB01 files to this document. Please try again');</script>"

		Print "<script type='text/javascript'>history.back();</script>"

		End

	End If

End If

ItemBodyText			= doc.getFirstItem("body").Text

addtolog ItemBodyText 		

For i = 0 To Ubound(doc.HostDoc_ID)

	LBDocID 					= Trim(doc.HostDoc_ID(i))

	addtolog  Str(i) & " DocID -> " & LBDocID

	If (LBDocID <> "") Then

		Set LBdoc 				= LBdb.getdocumentbyUNID(LBDocID)

		Set RTItemLB01 = LBDoc.Getfirstitem("Body")

		Set RTItemdoc = doc.GetFirstItem("BodyAttach")

		Call RTItemdoc.AppendRTItem(RTItemLB01)

		

		If Trim(doc.HostDoc_DeleteMark(0)) = "6" Then

			LBDoc.Status = "Deleted"		

			LBDoc.save 1,0

		End If

	End If

Next 

doc.body = ItemBodyText

doc.HostDoc_ID = ""

doc.HostDoc_DeleteMark = ""	

addtolog "InsertLB01 closed without error."

Exit Sub

ErrorHandler:

ErrorHandling("Module: Insert LBO1 Statements -> " + LBDocID )

Resume endSub

endSub:

End Sub

ERROR MESSAGE:

HTTP Web Server: Lotus Notes Exception - Specified database is not currently open [/apps/…]

Thanks for your help

Best regards

Bhoopathy

Subject: Domino web server: Specified database is not currently open

Bhoopathy, have you seen this post? http://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/5f3ae67639de7f2f85256e4d00093463?OpenDocument

Maybe it helps if you switch to the notesembeddedobject class…

Cheers, Christoph