Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Questions about SQL connection handle
Message
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00894503
Message ID:
00894521
Views:
12
The public is there because we set it in a startup .PRG, then it is available to everything else (forms, programs, reports, etc.) in the application.

We knew about generating an error, but wondered if there was a simple check to see if the connection is still valid, a one-liner of sorts and what to do about it if the connection has been lost. Seems the checking error method is a bit of a work-around.



>>>>>>>>>>>>

Do not know your reason to use a public variable. Private variable would be released on the application quit.

If connection is invalid, then any command with gnConnectionHandle will generate the error "Connection Handle is invalid". Thus you can use the custom on error routine to get the error and to act accordingly.

You can play with something like this to get the error and to create your error routine:

gnConnectionHandle = SQLSTRINGCONNECT(lcConnectionString)
sqldisc(0)
?sQLgetPROP(gnConnHandle, "ConnectBusy")


>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.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform