#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
|