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

问题描述

当我尝试使用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 ?

推荐答案


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

09-06 03:58