判断SQL表是否存在语句出错,请指教
On Error Resume NextDim rstSchema As New ADODB.Recordset
Dim adoCN As New ADODB.Connection
Dim findTable As String
findTable = "dbo.SZUsrtable"
adoCN.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Password=sz!2345;Initial Catalog=master;Data Source=(local)"
adoCN.Open
Set rstSchema = adoCN.OpenSchema(adSchemaTables)
rstSchema.Find "TABLE_Name='" & findTable & "'"
If rstSchema.EOF Then
MsgBox "没有"
Else
MsgBox "有"
End If
rstSchema.Close
------------运行后老是显示没有,无论表是否存在 --------------------编程问答-------------------- if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[表名]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) --------------------编程问答-------------------- 我是在VB的环境下的,谢谢
补充:VB , 数据库(包含打印,安装,报表)