各位高手:
我写了这样一段代码:
private static bool DeleteTable(SqlCeConnection cn, string TableName)
{
string strSQL = @"DROP TABLE IF EXISTS " + TableName ;
try
{
if (cn.State != ConnectionState.Open)
{
cn.Open();
}
SqlCeCommand SqlCeCmd = new SqlCeCommand(strSQL, cn); SqlCeCmd.ExecuteNonQuery();
return true;
}
catch (SqlCeException ex)
{ MessageBox.Show( ex.Message);
return false;
}
}
报错:Token line number=1 ,token line offset=12,Token in error=IF
调用语句是DeleteTable(cn, "xzqy")
我跟进去了,看到连接都没问题,字符串是DROP TABLE IF EXISTS xx(我的表名),但是还是抛出异常希望各位大侠赐教,不生感激阿!!
我写了这样一段代码:
private static bool DeleteTable(SqlCeConnection cn, string TableName)
{
string strSQL = @"DROP TABLE IF EXISTS " + TableName ;
try
{
if (cn.State != ConnectionState.Open)
{
cn.Open();
}
SqlCeCommand SqlCeCmd = new SqlCeCommand(strSQL, cn); SqlCeCmd.ExecuteNonQuery();
return true;
}
catch (SqlCeException ex)
{ MessageBox.Show( ex.Message);
return false;
}
}
报错:Token line number=1 ,token line offset=12,Token in error=IF
调用语句是DeleteTable(cn, "xzqy")
我跟进去了,看到连接都没问题,字符串是DROP TABLE IF EXISTS xx(我的表名),但是还是抛出异常希望各位大侠赐教,不生感激阿!!
DROP TABLE
drop table tbname
go
drop table tbname
go
drop table tbname
go
drop table tbname
go或这样
首先谢过!
我想问一下,可是这个表如果是空的呢?也或者没有,select不久不成功了么?
drop table tbname
go
就是判断表是否为空 为空的话还DROP什么?
悬赏分:10 - 解决时间:2009-7-17 09:36
我备份的SQL语句中有这么一行,不知道是什么意思? 提问者: QQ41678438 - 二级最佳答案如果数据库中存在address_book表,就把它从数据库中drop掉。
备份sql中一般都有这样的语句,如果是数据库中有这个表,先drop掉,然后create表,然后再进行数据插入。 '网上竟然也有“drop table if exists **”这样的写法,不知道是什么数据库中的语句??'
就是嘛!不是有个 exists 么!!
我是不想让这个表存在啊。因为下面用到PULL,如果表存在它就失败了
drop table tt
drop table tt