为什么判断数据表老是出错

来源:百度知道 编辑:UC知道 时间:2024/05/16 15:52:09
有如下ASP代码:
<%
dim sql

tablename="yutao"

conn.execute("drop table yutao if exists yutao")

sql="create table "&tablename&"(ID Autoincrement,classid int,项目 char(255),数据类型 char(255))"
conn.execute(sql)

%>

可是老是运行错误,提示DROP TABLE 或 DROP INDEX 语法错误。

当然数据库链接是对的。去除那个判断就可以顺利运行得到预料结果。

怎么改正那一句判断数据表是否存在,存在则删除此表
是ACCESS数据库啊 高手快来啊

drop table if exists yutao

是SQLServer数据库吗?
conn.execute("if exists (select * from sysobjects where type = 'U' and name = 'yutao') drop table yutao")
Access的话你看看conn有没有GetTableNames之类的方法

SQL
if exists (select 1 from sysobjects where id = object_id('yutao') and type = 'U')
drop table TBS
go