怎么知道某个数据库中否存在某个表?在线!

风口猪炒股指标 创办人  2003-04-04 03:58:55
我想知道db.mdb中是否存在client表
...全文
7 点赞 收藏 6
写回复
6 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
BadCatw 2003-04-04
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
回复
DimVar 2003-04-04
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

回复
DimVar() 高
dao 和ado一样的道理
回复
抱歉我想用dao,有人会吗?
回复
DimVar 2003-04-04
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
回复
cbr7619 2003-04-04
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strCn As String

Set cn = New ADODB.Connection
strCn = "driver={SQL Server};server=srv;uid=sa;pwd=;database=pubs"

cn.Open strCn

Set rs = cn.OpenSchema(adSchemaTables)

Do Until rs.EOF

if rs!TABLE_NAME ="client" then
msgbox""
exit
else
rs.MoveNext
endif
Loop

rs.Close
cn.Close
回复
相关推荐
发帖

1187

社区成员

VB 数据库(包含打印,安装,报表)
申请成为版主
帖子事件
创建了帖子
2003-04-04 03:58
社区公告
暂无公告