ODBC Time connection lazarus / 16-Databases ---------------------------------------------------------------------- lcapitanache · 2024-05-27 19:23 Hello, I have an application in Lazarus that connects to a MS Access 2007 database that is on a shared resource on a local network through an ODBCConnection control. The program works correctly and I can perform SQL queries without any problem. However, I have noticed that when the computer hosting the database is not available, my Lazarus application hangs waiting for the connection. I have searched, but I see that the ODBCConnection control does not have a Timeout property to set. In this scenario, how could I set a connection timeout of, say, two seconds, so that I can display a database unavailable error message? ---------------------------------------------------------------------- Zvoni · 2024-05-28 05:38 Quote from: lcapitanache on May 27, 2024, 09:23:03 pmHello, I have an application in Lazarus that connects to a MS Access 2007 database that is on a shared resource on a local network through an ODBCConnection control. The program works correctly and I can perform SQL queries without any problem. However, I have noticed that when the computer hosting the database is not available, my Lazarus application hangs waiting for the connection. I have searched, but I see that the ODBCConnection control does not have a Timeout property to set. In this scenario, how could I set a connection timeout of, say, two seconds, so that I can display a database unavailable error message? Since Access is a filebased database, why don't you just check if the FileExists (hint!)? EDIT: Found this: https://forum.lazarus.freepascal.org/index.php?topic=57218.0 Funny enough: Didn't remember anymore... No idea if it works for Access ---------------------------------------------------------------------- lcapitanache · 2024-05-29 19:29 Quote from: Zvoni on May 28, 2024, 07:38:00 amQuote from: lcapitanache on May 27, 2024, 09:23:03 pmHello, I have an application in Lazarus that connects to a MS Access 2007 database that is on a shared resource on a local network through an ODBCConnection control. The program works correctly and I can perform SQL queries without any problem. However, I have noticed that when the computer hosting the database is not available, my Lazarus application hangs waiting for the connection. I have searched, but I see that the ODBCConnection control does not have a Timeout property to set. In this scenario, how could I set a connection timeout of, say, two seconds, so that I can display a database unavailable error message? Since Access is a filebased database, why don't you just check if the FileExists (hint!)? EDIT: Found this: https://forum.lazarus.freepascal.org/index.php?topic=57218.0 Funny enough: Didn't remember anymore... No idea if it works for Access Hi, thank you very much for your time. I tried your idea of verifying the existence of the database file first, but I had exactly the same problem. The application hangs looking for the existence of the file on the host. I solved the problem by changing the approach a bit. What I did was to elaborate a function that sends a ping to the computer host, and based on its response I either open the database or display an unavailability error message.