连接MySQL时出现C#捕获错误 [英] C# Catching Error while connecting to MySQL

查看:80
本文介绍了连接MySQL时出现C#捕获错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,这是一个场景,当我试图将我的程序用于其他网络并且该PC没有互联网连接时,我想尽快捕获错误,这将提示用户没有连接到任何网络,现在它投掷,它没有连接到MySql,有时它等待和挂起等待连接我希望有人可以帮我这个,BTW我使用MysqldataReader登录

解决方案

由于您需要检查是否存在连接,您可以使用if语句来执行此操作,如果是,则继续;否则显示消息以避免挂起,请使用

 My.Computer.Network.IsAvailable()


Hello, here's the scenario, when im trying to use my program to other network and that PC doesnt have internet connection, I want to catch the error as soon as possible, that will prompt that the user isn't connected to any network, coz now its throwing that it doesnt connect to MySql, and sometimes it waits and hangs to wait for the connection" i Hope someone can help me with this, BTW im using MysqldataReader to Login

解决方案

Since you need to check if there is a conection, you can use an if statement to do that, if so, proceed; otherwise show a message to avoid the hangup, use

My.Computer.Network.IsAvailable()


这篇关于连接MySQL时出现C#捕获错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆