Access开发培训
网站公告
·Access专家课堂QQ群号:151711184    ·Access快速开发平台下载地址及教程    ·欢迎加入Access专家课堂微信群!    ·如何快速搜索本站文章|示例|资料    
您的位置: 首页 > 技术文章 > 综合其它

acc本身的Dlookup,Dmax等函數应用速度測試

时 间:2008-07-11 17:06:06
作 者:fuyvn   ID:43  城市:江阴
摘 要:acc本身的Dlookup,Dmax等函數应用速度測試
正 文:

 

經本人測度.   AC 自帶  Dlookup  ,Dmax 與  用 ADO  編寫的相應的替代函數 ,    速度 比較結果如下.

先便出  用 ADO 寫的相應的 替代函數.

Public Conn As New ADODB.Connection     'Conn

'mLookUp  替代  AC中的  Dlookup
Public Function mLookUp(ByVal strFieldName As String, ByVal strTableName As String, Optional ByVal strWhere As String) As Variant
    Dim sql As String
    sql = "select " & strFieldName & " From " & strTableName
    If Len(strWhere) > 0 Then sql = sql & " where " & strWhere
    On Error Resume Next
    mLookUp = Conn.Execute(sql)(0)
    If Err <> 0 Then
        Err.Clear
        mLookUp = Null
    End If
End Function

'mMax  替代  AC中的  DMax
Public Function mMax(ByVal strFieldName As String, ByVal strTableName As String, Optional ByVal strWhere As String) As Variant
    Dim sql As String
    sql = "select Max(" & strFieldName & ") From " & strTableName
    If Len(strWhere) > 0 Then sql = sql & " where " & strWhere
    On Error Resume Next
    mMax = Conn.Execute(sql)(0)
    If Err <> 0 Then
        Err.Clear
        mMax = Null
    End If
End Function

Public Function OpenConn() As Boolean
    On Error Resume Next
    Set Conn = CurrentProject.Connection
    'Conn.Open "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = \\Server\all_user\TOFuyvn\db1.mdb"
    If Conn.State = adStateClosed Then
        OpenConn = False
    Else
        OpenConn = True
    End If
End Function

測度結果:
      具體數據就不一一例出.     我在群中都有發過.

結論:

如果數據庫在本機上 :     Dlookup 及 DMax  比   mLookup  及 mMax   要快  70% 左右.

如果數據庫 在  局域網中的 其它電腦上,  將表 連接到 本機上:      mLookup 及 mMax 比  Dlookup 及 DMax  快5 倍以上.

如果是 ADP  遠程連接 SQL 數據庫:     mLookup 及 mMax 比  Dlookup 及 DMax  快 4 倍以上.


以上只是本人 自己測試的 結論,   不代表其它人的意見.  只做 參考用.


Access软件网QQ交流群 (群号:483923997)       Access源码网店

常见问答:

技术分类:

相关资源:

专栏作家

关于我们 | 服务条款 | 在线投稿 | 友情链接 | 网站统计 | 网站帮助