想請問一個問題:
小弟在利用ADO串連ADODC,並利用DataGrid來顯示資料時,輸入下列程序:
Private Sub adoData_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
adoData.Caption = "查詢結果" & ":" & _
adoData.Recordset.AbsolutePosition & _
"/" & DataCounts(adoData.Recordset, adoData.RecordSource)
End Sub
可是一執行就會發生編譯錯誤,可是小弟又找不到任何原因,是否ADODC之
MoveComplete事件在使用上有限制?
其中DataCounts為一函數:
Public Function DataCounts(tmpRs As ADODB.Recordset, tmpSQL As String) As Long
Dim countRs As New ADODB.Recordset
Dim StartStr As String
Dim EndStr As String
StartStr = InStr(tmpSQL, "FROM")
EndStr = InStr(tmpSQL, " ORDER")
countRs.Open "SELECT COUNT(*) AS 筆數 " & Mid(tmpSQL, StartStr, EndStr - StartStr), tmpRs.ActiveConnection
DataCounts = countRs("筆數")
countRs.Close
End Function