首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > ASP >

asp怎么判断表名

2012-03-31 
asp如何判断表名ASP在查询SQL数据库时,如果查询的表名在SQL中没有,应该如何弹出错误?[解决办法]VBScript c

asp如何判断表名
ASP在查询SQL数据库时,如果查询的表名在SQL中没有,应该如何弹出错误?

[解决办法]

VBScript code
<%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 sConnSet oCat = CreateObject("ADOX.Catalog")Set oCat.ActiveConnection = connSet colTables = oCat.Tablesb = FalseFor Each t In colTables    If t.Name = sTable Then        b = True        Exit For    End IfNextconn.CloseSet conn = NothingSet oCat = NothingSet colTables = NothingIf b Then    Response.Write "存在" & sTableElse    Response.Write "不存在" & sTableEnd If%> 

热点排行