找回密码
 加入
搜索
查看: 2074|回复: 0

[系统综合] ado获取access表名

[复制链接]
发表于 2013-4-26 10:22:07 | 显示全部楼层 |阅读模式
#Include <String.au3>
#Include <Array.au3>
#Include <File.au3>
#Include <Date.au3>
#Include <Misc.au3>
#include <Debug.au3>

; =======================================================================================================================
; 函  数: Com错误处理
; 日  期: 00:07 2013-04-03
; 说  明: 
; =======================================================================================================================
Global $oErr, $oMsg, $oErrLine
$oErr = ObjEvent("AutoIt.Error","MyErrFunc")
Func MyErrFunc()
        $oMsg &= StringFormat( "第 %u 行 : [%s]\n", $oErr.ScriptLine, $oErr.DeScription )
        $oErrLine = StringFormat( "第 %u 行 : [%s]\n", $oErr.ScriptLine, $oErr.DeScription )
    Return SetError( hex($oErr.Number ) )
Endfunc

Dim $Cn1 = ObjCreate('Adodb.Connection')
Dim $Rs1 = ObjCreate('ADODB.Recordset')

With $Cn1
    .Provider = "Microsoft.Jet.OLEDB.4.0;"
    .Properties("Data Source") = @ScriptDir & "\数据111.mdb"
    .Properties("Jet OLEDB:Database Password") = ""
    .CursorLocation = 3          ;3=adUseClient
    .Open
EndWith
        msgbox(48,$Cn1.Version,TblExist("表1"))
        msgbox(48,0,$oMsg)
$Cn1.Close

Func TblExist( $tbl_Name, $tbl_type="TABLE" )
        ;'Const adSchemaTables = 20
        ;'Const adSchemaViews = 23
        ;'Const adSchemaColumns = 4
        Local $result
        ;Array(TABLE_CATALOG,TABLE_SCHEMA,TABLE_NAME,TABLE_TYPE)
        dim $array[4] = ["","", "","TABLE"]
        ;同样的语句在VBS语法为  Set Rs1 = Cn1.OpenSchema(20, Array(Empty,Empty,Empty,"table") )
        ;                       能正常读取表名,为什么在AU3下却报错呢
        $Rs1 = $Cn1.OpenSchema(20, $array )
        $result = $Rs1.RecordCount
        $Rs1.Close
        Return $result
EndFunc
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-19 18:22 , Processed in 0.076061 second(s), 22 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表