Page 1 of 1

Constant Database Connection

Posted: Thu Sep 12, 2013 12:48 pm
by elanorb
Hi

As requested here is an example of a function that will work around the issue of losing a database connection, perhaps due to it timing out for some another reason.

The basic idea is to use a function to return the database id when you need it, this function checks if the current connection is still open and if not opens a new connection automatically.

Code: Select all

function databaseGetConnectionID
   if sDatabaseConnectionID is among the lines of revOpenDatabases() then
      return sDatabaseConnectionID
   else
      databaseConnect the uOptionText of group "databaseType" of card "contacts"
      return sDatabaseConnectionID
   end if   
end databaseGetConnectionID
I hope that is useful.

Kind regards

Elanor

Re: Constant Database Connection

Posted: Thu Sep 12, 2013 1:02 pm
by bangkok
I don't understand.

RevOpenDatabases() is going to check the reality/validity of each connexion ? I thought it just return a list of previously established connexion ID ?

Re: Constant Database Connection

Posted: Thu Sep 12, 2013 2:20 pm
by elanorb
The revOpenDatabases function returns a list of all the currently open database connections, so it can be used to check if a connection is still open.

Kind regards

Elanor