2017-06-07 76 views
0

我有一個表格下面的代碼,掛起,每當查詢仍在執行的形式:VB6,如何添加進度條上的SQL查詢(MySQL的)

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

MySQL並沒有告訴你完成一個查詢有多接近,它只能告訴你它已經運行了多長時間,或者什麼阻礙了進展,就像其他查詢阻止它一樣。

如果您有一個非常長時間運行的查詢,您需要猜測如果要計算ETA需要多長時間。

+0

謝謝! DoEvents不會。 –