• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 147
  • Last Modified:

Re-connecting to a Database and table after the connection is dropped

Hello All !  I have a Delphi 1.0 app that is running against SQL-AnyWhere Build 1867. The database does not have the -i option set which means the default for that option is in effect: that is, connections that are idle for four hours are disconnected.

But, lets say my user clicks the "refresh" button, five hours after the app has been idle.  Now, they get an error message that says:

"General SQL error [Sybase][ODBC Driver]
Connection not open;not connected to database"

Instead of getting/seeing that message, I want to handle the error and re-connect to the database and tables for the user without them knowing it or seeing it, and I want to refresh the app's data.  Can anyone offer advice?

1 Solution
Looks like a basic exception handling problem to me.

in the onClick event handler of the refresh button, put the following:

//          Display;
Except on EDatabaseError do
//           Disconnect;
//           Connect;
//           Display;
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now