'
----------------------------------------------------------
' Author: xmxoxo
' Update: 2006-11-28
' Version: 1.0.0
' ----------------------------------------------------------
' 参数:
' Conn 已打开的数据库连接
' strTableName 要查询的表名称
' 返回
' Boolean,True表示存在该表,False不存在.
' ----------------------------------------------------------
' 判断ACCESS数据库中是否存在某个表,VB语法
Function ExistTable(Conn As ADODB.Connection , Byval strTableName As String )
Dim blnRet As Boolean
Dim rstSchema As ADODB.Recordset
Const adSchemaTables = 20
blnRet = False
Set rstSchema = Conn.OpenSchema(adSchemaTables, Array ( Empty , Empty , strTableName, " TABLE " ))
If Not rstSchema.EOF Then
blnRet = True
End If
rstSchema.Close
Set rstSchema = Nothing
ExistTable = blnRet
End Function
' ----------------------------------------------------------
' 判断ACCESS数据库中是否存在某个表,VBScript语法,用于ASP
Function ExistTable(Conn , Byval strTableName )
Dim blnRet
Dim rstSchema
Const adSchemaTables = 20
blnRet = False
Set rstSchema = Conn.OpenSchema(adSchemaTables, Array ( Empty , Empty , strTableName, " TABLE " ))
If Not rstSchema.EOF Then
blnRet = True
End If
rstSchema.Close
Set rstSchema = Nothing
ExistTable = blnRet
End Function
' Author: xmxoxo
' Update: 2006-11-28
' Version: 1.0.0
' ----------------------------------------------------------
' 参数:
' Conn 已打开的数据库连接
' strTableName 要查询的表名称
' 返回
' Boolean,True表示存在该表,False不存在.
' ----------------------------------------------------------
' 判断ACCESS数据库中是否存在某个表,VB语法
Function ExistTable(Conn As ADODB.Connection , Byval strTableName As String )
Dim blnRet As Boolean
Dim rstSchema As ADODB.Recordset
Const adSchemaTables = 20
blnRet = False
Set rstSchema = Conn.OpenSchema(adSchemaTables, Array ( Empty , Empty , strTableName, " TABLE " ))
If Not rstSchema.EOF Then
blnRet = True
End If
rstSchema.Close
Set rstSchema = Nothing
ExistTable = blnRet
End Function
' ----------------------------------------------------------
' 判断ACCESS数据库中是否存在某个表,VBScript语法,用于ASP
Function ExistTable(Conn , Byval strTableName )
Dim blnRet
Dim rstSchema
Const adSchemaTables = 20
blnRet = False
Set rstSchema = Conn.OpenSchema(adSchemaTables, Array ( Empty , Empty , strTableName, " TABLE " ))
If Not rstSchema.EOF Then
blnRet = True
End If
rstSchema.Close
Set rstSchema = Nothing
ExistTable = blnRet
End Function
说明: 可以把"TABLE"改成"VIEW",来查询是否存在某个视图