Page 1 of 1

Database Connection Status Check

Posted: Tue Feb 16, 2010 2:04 pm
by kotikoti
Hi All,
Help please to get my head around this...

Need to test database connection status prior to inserting/updating content.

I have the following code in a test button.

Code: Select all

on mouseUp
  /* --------------------------------
  Test for DB connection
  --------------------------------- */
  if revopenDatabases() <> empty then
    
    wait 1 sec
    revclosedatabase gConID
    wait 1 sec
     
    #run SQL
    put empty into dbError
     
    put "select noteddID from Notes" into tSQL
    put revQueryDatabase(gConID,tSQL) into rsID
    handleRevDBerror the result
     
    if number of words of dbError = 1 then
      put "# of records in Notes:" && revNumberOfRecords(rsID) into fld "tDatabase"
      put the result into tResult
      handleRevDBerror tResult
    else
      put "resource id of open dbs:" && revopenDatabases() &cr&cr& dbError into fld "tDatabase"
    end if
     
  else
    answer "No Database is open" 
    exit mouseUp
  end if
   
end mouseUp
First stepping into the if statement while a connection exists is ok, but, I am knocking this connection out in code

Code: Select all

wait 1 sec
    revclosedatabase gConID
    wait 1 sec
to simulate a failure after the fact of the initial test. Doing this however results in the subsequent database task failing.

Code: Select all

put revQueryDatabase(gConID,tSQL) into rsID
I was hopping that the routine "handleRevDBerror the result" would have picked the error but code execution doesnt reach here since the debug already bombs out at the point. Any ideas on how I should be approaching this?

kotikoti.

Re: Database Connection Status Check

Posted: Tue Mar 02, 2010 9:53 am
by Mark
kotikoti,

What is your handleRevDBerror script? If the database can't be reached, you should get an error message. I have never had problems with that.

Best,

Mark