Can anyone tell me why this code is not opening the dbsurvey database? I’m stumped.
Set db = session.CurrentDatabase
path = Strleftback(db.FilePath,db.FileName)
Set dbsurvey = session.GetDatabase(db.Server,path+“Survey.nsf”)
If dbsurvey.IsOpen Then
Can anyone tell me why this code is not opening the dbsurvey database? I’m stumped.
Set db = session.CurrentDatabase
path = Strleftback(db.FilePath,db.FileName)
Set dbsurvey = session.GetDatabase(db.Server,path+“Survey.nsf”)
If dbsurvey.IsOpen Then
Subject: session.GetDatabase problem
Hi leo
i would suggest using profile document to get the servername and databasename instead the way you had chosen.
As you would have know about the Profile documents. if not just search the help on how to create one.
i will just tell an intro abt the profile documents. just create a form and uncheck the option include in search builder, include in menu etc. n the form properties and give the form name as ProfileDocument. then place two fields on the form namely. Server and dbname. Then on your code declare two variables namely servername and dbname then use the following code to obtain the profile field values.
eg. servername=profiledoc.getitemvalue(“server”)(0)
dbname=profiledoc.getitemvalue("dbnamme")(0)
then use set dbsurvey=session.getdatabase(servername,dbname)
it will work fine. One advantage on using this method id you can manually set the server and database paths in the profile document as whatever you wish and the code will look for the specified db. if on Migrating the db to another server u can just give the location rightaway in the profile document.
and another thing about the profile documetn is always you should open the document in edit mode to update or to save server and dbname.
also a few comments about Your code. You have given
session.getdatabase(db.server,path+“survey.nsf”)
remember that most of the time for the server value you have to give only the CN name of the server as the abvove mentioned code gives CN/O value so it might not work most of the time. and also iam not sure of giving the path+“survey.nsf” for dbname . think what will happen if you encounter two subfolders. thats all.
Hope that Helps you.
VJ