'********************************************************* '* 名称:TableExists '* 功能:判断表是否存在(表名) '* 用法:TableExists(表名) adoCN是一个SQL的连接 '********************************************************* Public Function TableExists(findTable As String) As Boolean Dim rstSchema As New ADODB.Recordset Set rstSchema = adoCN.OpenSchema(adSchemaTables) rstSchema.Find "TABLE_NAME='" & findTable & "'" If rstSchema.EOF Then TableExists = False Else TableExists = True End If rstSchema.Close End Function
Set rs = New ADODB.Recordset sql = "select * from sysobjects where name='你的表名' and type='u'" rs.Open sql, conIf rs.BOF = True And rs.EOF = True Then '你的表就不存在 Else '表存在 End If
Set rs = New ADODB.Recordset sql = "select count(*) from sysobjects where type='u'" rs.Open sql, con 表的个数 = rs.Fields(0)
'* 名称:TableExists
'* 功能:判断表是否存在(表名)
'* 用法:TableExists(表名) adoCN是一个SQL的连接
'*********************************************************
Public Function TableExists(findTable As String) As Boolean
Dim rstSchema As New ADODB.Recordset
Set rstSchema = adoCN.OpenSchema(adSchemaTables)
rstSchema.Find "TABLE_NAME='" & findTable & "'"
If rstSchema.EOF Then
TableExists = False
Else
TableExists = True
End If
rstSchema.Close
End Function
sql = "select * from sysobjects where name='你的表名' and type='u'"
rs.Open sql, conIf rs.BOF = True And rs.EOF = True Then
'你的表就不存在
Else
'表存在
End If
sql = "select count(*) from sysobjects where type='u'"
rs.Open sql, con
表的个数 = rs.Fields(0)