Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Handling DBEngine, DBSession and DBDatabase connection
Thu, Feb 12 2015 4:39 PMPermanent Link

Trinione

Hi:
What is the best/suggested way to handle connection to ensure any issues are caught and reported gracefully to the user?

Starting with the DBEngine, what if it is not started or not found.
Then, if the DBEngine is found, checking for the Session.
Then, if those are fine - ensuring that the DBDatabase is fine.

Trinione
Fri, Feb 13 2015 3:00 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Trinione


>What is the best/suggested way to handle connection to ensure any issues are caught and reported gracefully to the user?
>
>Starting with the DBEngine, what if it is not started or not found.
>Then, if the DBEngine is found, checking for the Session.
>Then, if those are fine - ensuring that the DBDatabase is fine.

I don't know about others but I don't specifically start / open / set active true for the engine, session or database. I simply set properties and start opening tables.

If the engine isn't found it means that someone has hacked your code - don't report this gracefully go in with an Uzi SmileyOn the other hand, if you mean the server, then the process below should work.

Overall if you want to go through the hirearchy the best approach is to

1) set all the necessary properties and then try to login
2) use the OnLogin / OnLogMessage events to see if you've been successful  eg in my app I have

except
 on E: Exception do begin
  if (E is EEDBError) then begin
   case EEDBError(E).ErrorCode of
    504: ShowError('504: Maximum connections exceeded');
    1100: ShowError('1100: Unable to establish remote logon');
   else ShowError('Invalid System Code, User ID or Password');
   end;
  end else ShowError('Invalid System Code, User ID or Password');
 end;

in a try except block

3) Once you're logged in you can query the configuration database (eg select * from configuration.databases) which will give a list of what databases should be there and you can iterate through and test for the path being valid and the catalog  file being there making sure that if you've customised things you use your file name.

4) You can then run a validate query on all the tables to make sure they're OK and do any other checks that you think are necessary.

The reason I don't suggest itatating through and checking that table files exist on disk is that they may not. Table files are only created from the information in the catalog when they are first used.

Roy Lambert
Image