Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB General » View Thread |
Messages 1 to 5 of 5 total |
Checking connectivity to server at program startup |
Wed, Jan 12 2011 9:43 PM | Permanent Link |
Oliver METTRIX | Not sure if this is the forum to ask the following:
I've written a small app in Delphi 2010 that uses EDB and that works great. Now I am working on the exception processing so that mishaps are handled cleanly. The first item i wish to check is the availability of a connection to my remote server. The way I do it now is by wraping a try ... except around the very first ExecSQL statement that my program expects to encounter. If I get an exception it's probably because I have no connection and I handle it with a message to the user followed by terminating the application. This doesn't seem to be the neatest or best way to accomplish what I'm trying to do. What is suggested as a proper way to check the availability of the server? Seems this should be checked even before attempting to execute a query or any other SQL statement. My program consists of one datamodule that holds an engine, a session, a database, and a query component, plus one main form. Thanks Oliver |
Thu, Jan 13 2011 5:56 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Oliver
I don't know about client/sever but in file/server I'd try opening the session or the database. Roy Lambert |
Thu, Jan 13 2011 10:14 AM | Permanent Link |
Uli Becker | Oliver,
> This doesn't seem to be the neatest or best way to accomplish what I'm trying to do. What is suggested as > a proper way to check the availability of the server? Seems this should be checked even before attempting > to execute a query or any other SQL statement. This is the code, I use in all my applications: procedure Tdm.DataModuleCreate(Sender: TObject); begin try MySession.Connected := true; except on E: Exception do begin if (E is EDatabaseError) and (E is EEDBError) then begin if (EEDBError(E).ErrorCode = EDB_ERROR_CLIENTCONN) then begin Application.MessageBox('No connection possible.', Global.titel, 16); halt; end else begin Application.MessageBox(PChar('Database Error # ' + IntToStr(EEDBError(E).ErrorCode)), Global.titel, 64); halt; end; end else begin Application.MessageBox('Unknown Database Error.', Global.titel, 16); halt; end; end; end; end; |
Wed, Jan 19 2011 7:00 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Oliver,
<< I've written a small app in Delphi 2010 that uses EDB and that works great. Now I am working on the exception processing so that mishaps are handled cleanly. The first item i wish to check is the availability of a connection to my remote server. The way I do it now is by wraping a try ... except around the very first ExecSQL statement that my program expects to encounter. If I get an exception it's probably because I have no connection and I handle it with a message to the user followed by terminating the application. This doesn't seem to be the neatest or best way to accomplish what I'm trying to do. What is suggested as a proper way to check the availability of the server? Seems this should be checked even before attempting to execute a query or any other SQL statement. >> I would have the TEDBSession try to connect via a special method added to the data module (call it Initialize or something similar). That way you can control the connection process, including error trapping and possibly retrying the connection if it fails. -- Tim Young Elevate Software www.elevatesoft.com |
Fri, Jan 21 2011 7:27 PM | Permanent Link |
Oliver METTRIX | Ulrich, thank you. I will study the code and adapt.
Oliver Uli Becker wrote: Oliver, > This doesn't seem to be the neatest or best way to accomplish what I'm trying to do. What is suggested as > a proper way to check the availability of the server? Seems this should be checked even before attempting > to execute a query or any other SQL statement. This is the code, I use in all my applications: procedure Tdm.DataModuleCreate(Sender: TObject); begin try MySession.Connected := true; except on E: Exception do begin if (E is EDatabaseError) and (E is EEDBError) then begin if (EEDBError(E).ErrorCode = EDB_ERROR_CLIENTCONN) then begin Application.MessageBox('No connection possible.', Global.titel, 16); halt; end else begin Application.MessageBox(PChar('Database Error # ' + IntToStr(EEDBError(E).ErrorCode)), Global.titel, 64); halt; end; end else begin Application.MessageBox('Unknown Database Error.', Global.titel, 16); halt; end; end; end; end; |
This web page was last updated on Tuesday, May 7, 2024 at 06:25 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |