New Posts New Posts RSS Feed: Checking Connection to a Web Database
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Checking Connection to a Web Database

 Post Reply Post Reply
Author
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Topic: Checking Connection to a Web Database
    Posted: 15-Jun-2009 at 10:04am
CheckDataSourceKey, in order to validate the connection information, will open up a test connection to the DB.  If all you need is to determine if the server hosting the DB is available, then PingServer(url) in IdeaBlade.Util.HttpFns might help.  Note that ping will take the URL for the server, so you'll have to build it up from information in the connection string.
 
You can multi-thread the PingServer call without potential problems.  CheckDataSourceKey is probably safe to use multi-threaded, but it would still be a better idea to make that call from another PM when using a separate thread.
 
You don't need to use DevForce to check the internet connection - the System.Net.NetworkInformation namespace contains some useful classes, such as Ping or NetworkInterface, which may do what you need.
Back to Top
*Calsy View Drop Down
Groupie
Groupie


Joined: 02-Feb-2009
Location: Australia
Posts: 69
Post Options Post Options   Quote *Calsy Quote  Post ReplyReply Direct Link To This Post Posted: 14-Jun-2009 at 8:17pm
Hi All,
During the load of our application we need to check if the user can access an SQL DB via the web and set a system boolean which we will then refer to. We use the following code:

 Dim x As IdeaBlade.Util.IdeaBladeConfig = IdeaBlade.Util.IdeaBladeConfig.Instance
            x.RdbKeys(1).Connection = "SQLConnectionGoesHERE"

            BO.SystemProperties.PMWebConnection = New PersistenceManager(True, "Key")

            If BO.SystemProperties.PMWebConnection.CheckDataSourceKey("Key") = DataSourceKeyStatus.UnableToConnect Then
                BO.SystemProperties.IsUserPortalConnected = False
            Else
                BO.SystemProperties.IsUserPortalConnected = True
            End If

This does work however when the CheckDataSourceKey section runs and there is no internet connection available it can take up to 15 seconds until it moves to the next line.

Is there a better(quicker) way to do this or is there a safe way I can multi-thread the database connection check as this is just too long for the user to wait.

Thanks
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down