asp如何判断表名

loujinmiao 2012-02-12 09:21:44
ASP在查询SQL数据库时,如果查询的表名在SQL中没有,应该如何弹出错误?
...全文
56 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
hookee 2012-02-13
  • 打赏
  • 举报
回复

<%
sConn = "Provider=SQLOLEDB;Data source=127.0.0.1;Initial Catalog=DB;User ID=sa;Password=sa;"
sTable = "table_name"
Set conn = CreateObject("ADODB.Connection")
conn.Open sConn
Set oCat = CreateObject("ADOX.Catalog")
Set oCat.ActiveConnection = conn
Set colTables = oCat.Tables
b = False
For Each t In colTables
If t.Name = sTable Then
b = True
Exit For
End If
Next
conn.Close
Set conn = Nothing
Set oCat = Nothing
Set colTables = Nothing

If b Then
Response.Write "存在" & sTable
Else
Response.Write "不存在" & sTable
End If

%>
loujinmiao 2012-02-13
  • 打赏
  • 举报
回复
谢谢hookee,已成功

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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