我在表单中有以下代码,只要查询仍在执行,它就会挂起表单:
Public Function OpenRS(strSql As String) As ADODB.Recordset
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.CursorType = adOpenDynamic
If IsNull(Cn) = False Then
rs.Open strSql, Cn, adOpenKeyset, adLockPessimistic ', adAsyncExecute
End If
Set OpenRS = rs
End Function
尝试添加adAsyncExecute但表单已关闭。
Dim RSC As ADODB.Recordset
Set RSC = Nothing
Set RSC = Cn.Execute("CALL SP_Rank_by_Company('" & MyDate1 & "','" & MyDate2 & "','DELETE')", , adAsyncExecute)
While Cn.State = 4
If frmLoadingReports.picLoading.Width = 5320 Then
frmLoadingReports.picLoading.Width = 0
Else
frmLoadingReports.picLoading.Width = frmLoadingReports.picLoading.Width + 100
End If
'count total records
'get the current number of records processed
DoEvents
Wend
如何向其添加进度条?
谢谢!
答案 0 :(得分:0)
MySQL没有告诉你查询完成的接近程度,它只能告诉你它运行了多长时间或阻碍进度的因素,就像其他查询阻止它一样。
如果你有一个非常长时间运行的查询,你需要猜测你想要计算ETA需要多长时间。