how to display mongodb.connection status?

185 views
Skip to first unread message

yibin

unread,
Jun 2, 2011, 9:05:25 PM6/2/11
to mongodb-csharp
mongo.TryConnec()?
how to display mongodb.connection status?

Robert Stam

unread,
Jun 2, 2011, 9:12:06 PM6/2/11
to mongodb-csharp
With the official C# driver you can query the value of the
MongoServer.State property, which will have one of the following
values:

public enum MongoServerState {
None = 0,
Disconnected,
Connecting,
Connected
}

Note that this value is not maintained in real time. It is current *as
of* the last operation performed against the server.

You can call MongoServer.Ping() to test whether the server is
reachable (which will also update the State property).
Reply all
Reply to author
Forward
0 new messages