Hi All,
probably a trivial question, but how do I handel errors occuring when for example my sql server is down, or there is some other problem conecting to the database?
try .. except
Thnks
Simon
exception handeling connecting tot mysql server/database
You can process an exception on connecting like this:
Code: Select all
try
MyConnection.Connect;
except
on e: EDAError do
if e.Message = '' then
// processing of message
end;Then you can use the SocketException class, or the Exception class, like this:
Code: Select all
try
MyConnection.Connect;
except
on e: EDAError do
// processing of message
on e: SocketException do
// processing of message
on e: Exception do
// processing of message
end;When de server is not available, and thus the mysql database not reachable the statement myconnection.connect generates the error:
.. raised exception class SocketException...
The advice given above generates a compilation error in the statement:
on e: SocketException do
because SocketException is not known.
Probably I must ad a unit to the uses clause? Which? I could not find it in the help
.. raised exception class SocketException...
The advice given above generates a compilation error in the statement:
on e: SocketException do
because SocketException is not known.
Probably I must ad a unit to the uses clause? Which? I could not find it in the help