Constant Database Connection

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Locked
elanorb
Livecode Staff Member
Livecode Staff Member
Posts: 516
Joined: Fri Feb 24, 2006 9:45 am

Constant Database Connection

Post by elanorb » Thu Sep 12, 2013 12:48 pm

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
Elanor Buchanan
Software Developer
LiveCode

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: Constant Database Connection

Post by bangkok » Thu Sep 12, 2013 1:02 pm

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 ?

elanorb
Livecode Staff Member
Livecode Staff Member
Posts: 516
Joined: Fri Feb 24, 2006 9:45 am

Re: Constant Database Connection

Post by elanorb » Thu Sep 12, 2013 2:20 pm

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
Elanor Buchanan
Software Developer
LiveCode

Locked

Return to “Summer School 2013”