Dim cn As ADODB.Connection Dim rs As ADODB.Recordset Dim strCn As StringSet cn = New ADODB.Connection strCn = "driver={SQL Server};server=srv;uid=sa;pwd=;database=pubs"cn.Open strCnSet rs = cn.OpenSchema(adSchemaTables) Do Until rs.EOF if rs!TABLE_NAME ="client" then msgbox"" exit else rs.MoveNext endif Looprs.Close cn.Close
rst.Open "select * from dbo.sysobjects where id = object_id(N'[dbo].[tblKeyVerification]') and OBJECTPROPERTY(id, N'IsUserTable') = 1", cnn If rst.BOF And rst.EOF Then MsgBox "table myTable not existed" Else MsgBox "table myTable existed" End If rst.Close
DimVar() 高 dao 和ado一样的道理
set rst=db.openrecordset("select * from dbo.sysobjects where id = object_id(N'[dbo].[tblKeyVerification]') and OBJECTPROPERTY(id, N'IsUserTable') = 1") If rst.BOF And rst.EOF Then MsgBox "table not exists" Else MsgBox "table exists" End If
dim tb as TableDef,yn as Boolean db.TableDefs.Refresh for each tb in db.TableDefs if lcase(tb.name)="client" then yn=true else yn=false endif next
Dim rs As ADODB.Recordset
Dim strCn As StringSet cn = New ADODB.Connection
strCn = "driver={SQL Server};server=srv;uid=sa;pwd=;database=pubs"cn.Open strCnSet rs = cn.OpenSchema(adSchemaTables) Do Until rs.EOF if rs!TABLE_NAME ="client" then
msgbox""
exit
else
rs.MoveNext
endif
Looprs.Close
cn.Close
If rst.BOF And rst.EOF Then
MsgBox "table myTable not existed"
Else
MsgBox "table myTable existed"
End If
rst.Close
dao 和ado一样的道理
If rst.BOF And rst.EOF Then
MsgBox "table not exists"
Else
MsgBox "table exists"
End If
db.TableDefs.Refresh
for each tb in db.TableDefs
if lcase(tb.name)="client" then
yn=true
else
yn=false
endif
next