Solved

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

Posted on 1998-09-29
1
137 Views
Last Modified: 2011-08-18
Hello All !  I have a Delphi 1.0 app that is running against SQL-AnyWhere 5.5.0.4 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?

Everett
0
Comment
Question by:ecrockett
1 Comment
 

Accepted Solution

by:
belgianbasman earned 100 total points
ID: 1341110
Looks like a basic exception handling problem to me.

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

try
   begin
//          Display;
   end;
Except on EDatabaseError do
   begin
//           Disconnect;
//           Connect;
//           Display;
   end;
END;
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now