Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Questions about SQL connection handle
Message
De
14/04/2004 10:44:03
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Divers
Thread ID:
00894503
Message ID:
00894772
Vues:
9
Mark,

As far as reconnecting if connection is dropped -

Create a connection handle property in an application object.

Assign an access method to this property, and in this method write the code to connect to SQL if the connection handle is invalid. Also in this access method check for a valid connection and trap any errors. If the connection is invalid, go into a DO WHILE loop and pop up a message box telling the user so, and give them the opportunity to try and reconnect or to close the application.

By using the access method for the connection handle property, anytime the connection handle is attempted to be used it will fire first, thus giving you an opportunity to capture an invalid connection before continuing with your code. It will also establish the connection the first time you try to use the connection handle stored in this property. I do not see any degredation in performance when using this method.

John



>When you do this ...
>
>PUBLIC gnConnectionHandle
>gnConnectionHandle = SQLSTRINGCONNECT(lcConnectionString)
>
>... (where lcConnectionString is a valid connection string to a SQL Server database), what is the lifespan and stability of gnConnectionHandle? That is, obviously it is a global variable, and is scoped to the application, but what if SQL Server is taken off line or some network problem severs the connection for the user or the user leaves the application idle all day/night/week/... (forgets to log off and goes on vacation for a month)?
>
>Also, what is the best way to check to confirm that gnConnectionHandle is still valid within the application, and if not reconnect to SQL Server?
>
>Any thoughts, pointers or leads to good information (links) on these issues would be appreciated.
>
>Thanks.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform