Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Permanent Database Connection 1

Status
Not open for further replies.

dkausa4851

Programmer
Mar 3, 2004
10
US
FoxPro needs a constant connection to the database. I have found that with Micosoft 2003 Server using Terminal Services, a pause from within Terminal Services occurs. This breaks the connection to the database and FoxPro falls on its face. Can someone give me a tip to possible trapping the broken connection or something I can do to stop the application from totally crashing. This forces the sys-admin person at the company using my app to kill the FoxPro app on the server.
To me it seems like a Microsoft issue but I get no help from them. I'm open for suggestions!!
 
When the connection is lost and VFP "crashes" do you get an error message?

If so you could use the ON ERROR command to send you to an ErrorHandler where the problem can be handled in a "graceful" manner and possibly restore the connection and then move on.

Good Luck,
JRB-Bldr
 
I've tried the On Error routine which does occur when the connection is broken but then FoxPro continues it's path to nowhere. The connection cannont be re-established and the commands to end processes, close databases and exit the program do not kill the application. It just errors and errors and errors until you Ctrl-Alt-Del.

 

dkausa4851,

Your On Error routine should display some useful information about the error, especially the error number and message.

Ideally, it should then gracefully close the application. That would avoid the "path to nowhere". Of course, in the long run, you need to find out why the connection is being broken and take steps to deal with it.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
The broken connection is coming from Terminal Services that runs with Server 2003. It is going into a 'pause' mode which is all the details I have. I don't know how long it lasts or how often it occurs but Microsoft has white paper on the fact that it does do this. This is what is breaking the connection to the database and puking my FoxPro app. Fox cannot recover from the loss of connection and the On Error routine will not bring down my app gracefully. What might you code in the on error besides to stop processes and exit. I wouldn't care to much if the user had to log into my app again, but the way it is now, the app hangs and the admin has to kill the process on the server.
 
Dkausa,

What might you code in the on error besides to stop processes and exit.

In summary, you need to revert any unsaved edits, rollback any transaction, close all open forms, CLEAR EVENTS, clear the ON SHUTDOWN handler, and QUIT. And, of course, issue a polite message to the user.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Forgive if I have misundersttod the problem here, but couldn't you just check that the connection is still valid before starting the process?

ie SQLCONNECT( MyHandle, "<some simple query or something that should definately work>")

... and if it returns a negative, reconnect, then run the process?

Or, although you may have an overhead with this, open the connection, do whatever, and then close the connection.

Is there a reason for it having to be open all the time?

I like work. It fascinates me. I can sit and look at it for hours...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top