超时异常 - 错误 [英] Timeout Exception - Error

查看:64
本文介绍了超时异常 - 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用ExecuteReader()命令从MySQL数据库中检索数据时,我收到如下超时错误:



TimeoutException未处理:连接尝试失败,因为连接方在一段时间后没有正确响应,或者由于连接主机无法响应而建立连接失败。



任何人都可以说明这种例外的可能原因。


代码的麻烦片段如下:



When I try retrive a data from a MySQL database using the ExecuteReader() command i receive a timeout error like this :

TimeoutException was unhandled : A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

Can any one state a possible reason for this exception.

The troublesome fragment of code is as under :

Dim connectionst As String = connectionstring   'String concealed 
 Dim querystring As String = "SELECT dat1 FROM mydb WHERE dat2 = '" + txtbox.Text + "';"
Dim commandgive As New MySqlCommand(querystring)
         Dim commandgive As New MySqlCommand(querystring)
        commandgive.Connection = connection
        connection.Open()
        Dim dataread As MySqlDataReader
        dataread = commandgive.ExecuteReader() 'Problematic code.
        MsgBox(dataread.GetInt32(0))

        dataread.Close()
        connection.Close()
connection.Close()





该行评论为ap roblematic代码是vb向我显示超时异常的地方。



为什么会这样?



The line commented a problematic code is where vb shows me a timeout exception.

Why is this so ?

推荐答案

好吧,你的连接字符串是错误的(很棒的工作可以隐藏重要的信息!)你并没有真正连接到你认为的那个或你的盒子MySQL服务器在允许执行命令的默认时间内没有响应查询结果(通常是30秒)。





由于缺乏提供的信息,所有人都可以告诉你。
Well, either your connection string is wrong (great job keeping an important piece of information hidden!) and you''re not really connecting to the box you think you are or your MySQL server didn''t respond with the query results in the default time allowed to execute the command (usually 30 seconds).


That''s about all anyone can tell you given the lack of information provided.


这篇关于超时异常 - 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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