But then i wanted that when i do anything that needed to connect to the database i would check if the connection still exists and if not to open a connection before doing anything. However when i forced my databse to drop the connection then tried to run something it doesnt like me using select if there is no connection. So i assume that one of the revDatabase commands that would be best to use to check if there is a connection and if not do something but not sure which is the best to use.
Code: Select all
on something
checkServer
do what needs to be done
end something
Code: Select all
on checkServer
put "SELECT COUNT(id) FROM connecttest WHERE testid ='1' " into trSQL
put revDataFromQuery(tab, cr, gConnectionID, trSQL) into trData
if trData <> 1 then
dbaseConnect
end if
end checkServer
Code: Select all
on dbaseConnect
put "xxxxx" into tDatabaseAddress
put "xxxxx" into tDatabaseName
put "xxxxx" into tDatabaseUser
put "xxxxx" into tDatabasePassword
put revOpenDatabase("MySQL", tDatabaseAddress, tDatabaseName, tDatabaseUser, tDatabasePassword) into tResult
if tResult is a number then
put tResult into gConnectionID
else
put empty into gConnectionID
answer error "Unable to connect to the database"
end if
end dbaseConnect