日期:2014-05-17 浏览次数:20685 次
protected void Button1_Click(object sender, EventArgs e)
{
//int X = Convert.ToInt32(Request.QueryString["tablename"]);
int countjieguo = tongjibiao();
int X = countjieguo - 2; //要减去系统必须的3个表
bool isexistbiao = isexist("table"+X.ToString());
if (isexistbiao == false)
{
string sqlstr = "create table table'" + X + "' (id int identity not null,title nvarchar(100),username nvarchar(100),time datetime,content ntext,class nvarchar(100))";
sqlEx(sqlstr);
//string strupdate = "insert into table'" + X.ToString() + "' (title,username,time,content) values ('" + TextBox4.Text.ToString() + "' , " + "' 1 '" + " ,'" + DateTime.Now + "', '" + TextBox1.Text.ToString() + "')";
//sqlEx(strupdate);
MessageBox.Show("发帖成功!");
}
else
{
MessageBox.Show("发帖失败,请重试!");
}
}
string sqlstr = "create table table'" + X + "' (id int identity not null,title nvarchar(100),username nvarchar(100),time datetime,content ntext,class nvarchar(100))"; --这一句中创建表 create table table'是不合法的
------解决方案--------------------
"create table table" + X + "
没有table'7'这样的名字。
去掉引号要么
"create table [table'" + X + "']..