这是我第一次使用后台工作者。我想检索大约20.000行的数据,将其保存在dataadapter上并显示在datagridview上
它似乎正在运行但后来消息Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding
出现了。
我所做的是将Connect Timeout=90000
放在连接字符串和da.SelectCommand.CommandTimeout = 2000000
上,这似乎没有更好的最终结果,因为添加了几个额外的零。 :(
这就是我所做的。我该怎么做才能使它有效。谢谢
Dim da As MySqlDataAdapter
Dim resultDataTable As DataTable
Dim queryString As String
Private Sub BTNrefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNrefresh.Click
queryString =" LONG QUERY "
bw.RunWorkerAsync()
End Sub
Private Sub bw_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles bw.DoWork
MethodGlobal.mySqlCon.Open()
da = New MySqlDataAdapter(queryString, MethodGlobal.mySqlCon)
myDataTable = New DataTable
da.Fill(myDataTable)
da.SelectCommand.CommandTimeout = 2000000
Me.DGVtest.DataSource = resultDataTable
End Sub
Private Sub backgroundworker_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
MethodGlobal.NewMysqlConnection("connection")
End Sub