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

风口猪炒股指标 2003-04-04 03:58:55
我想知道db.mdb中是否存在client表
...全文
33 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
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

网络老男孩了 2003-04-04
  • 打赏
  • 举报
回复
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

1,217

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧