Database has not been open yet

I encounter the error msg:“Database MOEA003!!\project\zs\sars.nsf has not been open yet” when i running the following code in the agent,

i want to get the database in another server,

server name is :MOE003/MOE/A

path is :project\zs\sars.nsf

Any help will be greatly appreciated.

Sub Initialize

'One time loading of school information from SARS database

Dim db As Notesdatabase

Dim Session As New NotesSession

Dim view As NotesView

Dim doc As NotesDocument

Dim itemAuthor As NotesItem, itemReader As NotesItem

Set db = Session.currentdatabase

Set view = db.GetView( “vwSchList” )

'For SchoolInfo form in Sars db

Dim SARSdb As notesdatabase

Dim SARSview As notesView

Dim SARSdoc As NotesDocument

Dim key As String

Dim counter As Integer

Set SARSdb = session.GetDatabase (“MOE003”, “\project\zs\sars.nsf”)

Set SARSview= SARSdb.GetView( “vSchoolInfoLkup” )

Set SARSdoc = SARSview.GetFirstDocument

counter = 0

'Loading starts

While Not ( SARSdoc Is Nothing )

counter = counter + 1

key = SARSdoc.Schcode(0)

Set doc = view.GetDocumentByKey( key , True )

'if school info doc does not exist

If ( doc Is Nothing) Then

Set doc = New NotesDocument ( db )

doc.Form = “SchList”

doc.SchoolCode = key

End If

'Update info if school info doc already exists

doc.SchoolName = SARSdoc.SchName(0)

Call doc.save( True, True )

Set SARSdoc = SARSview.GetNextDocument( SARSdoc )

Print "Counter : " & Cstr(counter)

Wend

Msgbox “Loading of school code and name has completed.” , MB_OK, “Information”

End Sub

Subject: Database has not been open yet

If that’s your actual code, you need to get rid of the "" at the beginning of your database path (in the getdatabase statement).

Subject: RE: Database has not been open yet

Thanks rogers, i remove the "" at the beginning of the database path to solve this problem

Subject: Database has not been open yet

Hi,session.getdatabase(),doesn’t mean to open the database compulsory.

Some times it may open or may not.So, use the below method after getdatabase(),

Call SARSdb.open();

still you are facing any problem,use any flag and then check its opening or not.

Thanks

Guru

Subject: Database has not been open yet

HI Breeze,In this type of problem you ve to do the following thing…

  1. Stop the server.“MOEA003/MOE/A”

  2. Compact the databse. “sars.nsf”

  3. Start the server agin and try to run the code.

But above all what i think you should ve look for the spelling of the server and database, and the folder in which the database is.It may create problem if these are wrongly spelled.