May 13, 2008

A couple of times in my recent past, I have experienced issues when I have a long running process working on SDE data that suddenly crashes.  On adding detailed logging in the code, I pinpointed the issue to the SDE connection being lost between the workstation and the server. One possible reason was our backup systems kicked in at mid-night causing the database to disconnect or maybe a network issue.

To add fault-tolerance in such cases, IWorkspaceFactoryStatus is a very handy interface. IWorkspaceFactoryStatus.WorkspaceStatus gives the current connected status to the SDE geodatabase. If the connection status is esriWCSDown, then use PingWorkspaceStatus method to check if the workspace can be reconnected to. If the PingWorkspaceStatus method returns a WorkspaceStatus of available, the open a new workspace. It is important to note that the old workspace can not be reclaimed.

ESRI Documentation is here and an interesting blog post on the topic is here