Session.ServerName problem

I have a piece of code in a VB Application, which connects to a database to retrieve a view. The problem is that I have the server name hard coded, but wish to change this so that I can create a session, get the name of the server which the session is connecting to, and then use that to connect to a replica of the database with the view.

The code I am using (which works) is this;

Dim session As Object

dim dbIndexer as Object

Set session = CreateObject("Notes.NotesSession")

Set dbIndexer = session.GetDatabase("ServerName", "WPIndex.nsf")

When I try to use the session.ServerName property to retrieve the users server name, I get an error stating that the object does not support the method.

Any ideas ?

Thanks

Vic

Subject: Session.ServerName problem

Hi,

just a little thing I see is that you didn’t initialized your session using

session.Initialize

before using any methods or properties. You should initilaze it just after the CreateObject. See exemple in Domino Designer help about ServerName property.

It also says :

This property is null if the session is not running on a server.

Hope it helps

Dave

Subject: RE: Session.ServerName problem

Dave,

Thanks for your reply.

I tried using session.initialise, but I get the same error on this line in my VB program (object doesn’t support property or method)

Is there another way of determininig the users home server from the session ?

Thanks

vic

Subject: RE: Session.ServerName problem

I think there’s some misunderstanding here about what the ServerName property is supposed to do.

You referred to the “user’s server name.” There is no “user’s” server in the context of a session object. ServerName is supposed to return the server on which the code is running. If the code runs on a user’s workstation, there is no current server.

You might be thinking of the user’s mail server; in that case you might want to look at OpenMailDatabase method.

In any case, to use methods and properties designated as “COM only,” you definitely need to use Lotus.NotesSession, not Notes.NotesSession, and you do need to call Initialize. Did you try the example in the Designer help?

Subject: RE: Session.ServerName problem

Andre,

Thanks for your explanation. I was obviously misinterpreting the use of the .ServerName property.

I will try to use the mail database instead, as you have suggested.

Thanks

Vic

Subject: Session.ServerName problem

Hi

Try:

dim dbIndexer as Object

Set session As NotesSession

Set session =CreateObject(“Lotus.NotesSession”)

Call session.Initialize

Set dbIndexer = session.GetDatabase(“ServerName”, “WPIndex.nsf”)

regards

Jesper Kiaer

http://www.jezzper.com

Subject: RE: Session.ServerName problem

Hi Jesper,

Tried this, but with the same error :frowning:

Thanks

Vic

Subject: This works…

Hi

I have just made a test in VB6 and this works.

Dim Session As New NotesSession

Dim Db As NotesDatabase

Session.Initialize

Set Db = Session.GetDatabase(“servername”, “databasename”)

MsgBox Db.Server, , “ServerName”

There is a bug in Session.ServerName …it returns an empty string, so get the servername from the database object instead

regards

Jesper Kiaer

http://www.jezzper.com

Subject: RE: This works…

Jesper,

Thanks for this, but to use your code, I will need to specify the server name for the mail database.

What I need to achieve is for the VB app to determine what the users home mail server is so that it can connect to it. I know I can do this by interrogating the notes.ini file, but I would rather not have to do it that way.

Thanks

Vic

Subject: RE: This works…

PLEASE see Andre’s response – it’s not a bug.