Print Page | Close Window

PersistenceServerException (occasional)

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2926
Printed Date: 23-Apr-2025 at 5:44am


Topic: PersistenceServerException (occasional)
Posted By: yongbum75
Subject: PersistenceServerException (occasional)
Date Posted: 25-Aug-2011 at 3:43pm
Hi, we have a small .NET Windows app written a couple of years ago that uses DF Classic.  It pulls data from a remote SQL server in our branch office.  Occasionally I think there are blips and our interoffice VPN connections get lost.  Needless to say, when it happens the app looses connection to the remote SQL server and returns the following error.  Is there any way to check the connection state and programmatically reconnect like you can with the ADO.NET connection object?  I tried PM.IsConnected() and PM.Connect() but it doesn't seem to work the way I expect it to.  Any insight/help would be greatly appreciated!  Thanks.

IdeaBlade.Persistence.PersistenceServerException: [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied. ---> System.Data.OleDb.OleDbException: [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.
  at IdeaBlade.Persistence.RemotingPersistenceServerProxy.CheckConnection(Exception pException)
  at IdeaBlade.Persistence.PersistenceServerProxy.Fetch(SessionBundle pBundle, IEntityQuery pQuery)
  at IdeaBlade.Persistence.PersistenceManager.XFetchDataSet(IEntityQuery pEntityQuery)
  --- End of inner exception stack trace ---
  at IdeaBlade.Persistence.PersistenceManager.HandlePersistenceServerException(Exception pException, Boolean pTryToHandle, PersistenceOperation pOperation)
  at IdeaBlade.Persistence.PersistenceManager.XFetchDataSet(IEntityQuery pEntityQuery)
  at IdeaBlade.Persistence.PersistenceManager.XFetch(IEntityFinder pEntityFinder, WorkState pWorkState)
  at IdeaBlade.Persistence.PersistenceManager.XFetch(IEntityQuery pEntityQuery, QueryStrategy pQueryStrategy, WorkState pWorkState)
  at IdeaBlade.Persistence.PersistenceManager.XGetEntities(IEntityQuery pEntityQuery, QueryStrategy pQueryStrategy, WorkState pWorkState)
  at IdeaBlade.Persistence.PersistenceManager.GetEntities[T](IEntityQuery pEntityQuery, QueryStrategy pQueryStrategy)
.....



Replies:
Posted By: kimj
Date Posted: 25-Aug-2011 at 5:20pm
PM.Connect and PM.IsConnected are related to the PersistenceManager's connection to the PersistenceServer, so won't tell you anything about database connectivity.  If you're not using a BOS the PM is always considered "connected".
 
To check whether you can connect to the database you can use PM.CheckDataSourceKey(keyname), or if you already have the RdbKey, key.CheckConnection().  Both methods do the same thing, and will try to open a connection to the database.
 
DevForce creates a new connection for every query or save, so there's no way to "reconnect" per se.  If the datasource cannot be reached the above methods will return "false", but there's no automatic retry or reconnect logic. 
 
If you suspect the network connection has been lost, you can also use the NetworkChange and NetworkInterface classes in .NET to help monitor connectivity.



Print Page | Close Window