如果找不到表怎么办?在线等!!!!!

imagex 2003-09-30 03:07:21
sql="select * from table1 where a>0"
rs.open sql ,conn

如果table1不存在,就会报错。
怎么避免这种现象?
怎样知道表存在不存在?
...全文
30 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
nchen123 2003-09-30
  • 打赏
  • 举报
回复
晕,你作的什么系统,需要操作者直接建表??
imagex 2003-09-30
  • 打赏
  • 举报
回复
可是表很多的!而且操作者不是很懂数据库
lovehwq21 2003-09-30
  • 打赏
  • 举报
回复
晕,那你起个表专门用来存表名的吧,每次检查一下这个表有没有你要查的那个表就行了
imagex 2003-09-30
  • 打赏
  • 举报
回复
晕!我用过不是很好啊!
qdjiaxin 2003-09-30
  • 打赏
  • 举报
回复
在conn后面应该加上1,1
sunnyBelt 2003-09-30
  • 打赏
  • 举报
回复
那就用:ON error resume next
imagex 2003-09-30
  • 打赏
  • 举报
回复
对了,我用的是ACCESS呀!!!!!!
哪里有什么sysobjects????
不好意思!!忘说了
chinanetspy 2003-09-30
  • 打赏
  • 举报
回复
if exists(select * from sysobjects where name="table1" and xtype="u")

加上这句应该没有什么问题
lang11zi 2003-09-30
  • 打赏
  • 举报
回复
既然查询怎么没表?
ghlfllz 2003-09-30
  • 打赏
  • 举报
回复
on error resume next
……
if err>0 then
'process code
end if
imagex 2003-09-30
  • 打赏
  • 举报
回复
xtype是什么意思?
lovehwq21 2003-09-30
  • 打赏
  • 举报
回复
在ASP里面
sql = "select name from sysobjects where name='table1' and xtype='U'"
rs.Open sql,conn,1,3
If not rs.EOF Then
Response.write "表不存在!"
Response.End
End If
rs.Close
lihua9666 2003-09-30
  • 打赏
  • 举报
回复
用错误捕获呀
junsunchen 2003-09-30
  • 打赏
  • 举报
回复
sql = "select name from sysobjects where name='tablename'"
rs.open sql,con,1,3
if not rs.eof then
response.write "表存在!"
else
response.write "表不存在!"
end if
lovehwq21 2003-09-30
  • 打赏
  • 举报
回复
错了,不对意思,type换成xtype
if exists(select * from sysobjects where name="table1" and xtype="u")
lovehwq21 2003-09-30
  • 打赏
  • 举报
回复
先检查是否有这个表
if exists(select * from sysobjects where name="table1" and type="u")
判断是否存在这个表,然后再写下面的语句
tanyaliji 2003-09-30
  • 打赏
  • 举报
回复
on error
if....
else if
.......
....
tanyaliji 2003-09-30
  • 打赏
  • 举报
回复
写个游标啊!

28,390

社区成员

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

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