急!c# asp.net这一句SQL语言执行有异常的?

来源:百度知道 编辑:UC知道 时间:2024/06/20 12:18:10
string str = "server='(local)';DataBase='EMR';User ID='sa';Password=''";
SqlConnection con = new SqlConnection(str);
con.Open();
string sql1 = "CREATE TABLE "+TextBox3.Text ;
SqlCommand com1 = new SqlCommand(sql1, con);
com1.ExecuteNonQuery();
我只是想创建一个表而已。。用c# asp.net这样写不行么~
回一楼:string str = "server='(local)';DataBase='EMR';User ID='sa';Password=''"; 这里是肯定没问题的。该表的列要以后才添加的

SQL语句不允许建立没有字段的表。不是C#,ASP.NET的原因。
你在SQL查询分析器中试验下就知道了。提示,语法错误的

string str = "server='(local)';DataBase='EMR';User ID='sa';Password=''"; 里不需要单引号了。
还有既然你要建表为什么不建立字段??

1.str中的字段不需要引号
2.不允许建立字段为空的表

估计没这个权限吧。。。。
create语句不是sql语言啊。。。
sql语言是架构化查询语言
create好像是SDL吧。。。。。

建议你用存储过程动态建表,,,
http://user.qzone.qq.com/80100568/blog/1231329505
这个网址有说动态修改表结构的,,

你的sql语句不完整
create table aa(_id int identity(1,1) not null)