Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个允许用户手动输入远程服务器名称的 VB6 应用程序。我需要使用用户提供的服务器名称连接到 MySQL 数据库。
如何检查用户输入的服务器是否有效并且我可以连接到它?
查看它是否有效以及您可以连接到它的唯一可靠方法是尝试连接到它。其他任何事情都会导致潜在的竞争条件(它在检查和实际使用之间变得无效)或有可能产生不正确的结果,因为您不会检查您真正想要做什么。