建立資料表時出錯
建立資料表時出錯 ?????
C# code
string connString = WebConfigurationManager.ConnectionStrings["CnString"].ConnectionString;
SqlConnection conn = new SqlConnection(connString);
conn.Open();
string SQL =("CREATE TABLE a (Id int NOT NULL ," + "Name varchar (30)," + "Subbranch varchar(30)," + "ErrorCode varchar(5)");
SqlCommand objCommand = new SqlCommand(SQL, conn);
objCommand.ExecuteNonQuery();
conn.Close();
conn.Dispose();
結果 :
接近 ')' 之處的語法不正確
objCommand.ExecuteNonQuery();
------解决方案--------------------不懂了?你这句话:string SQL =("CREATE TABLE a (Id int NOT NULL ," + "Name varchar (30)," + "Subbranch varchar(30)," + "ErrorCode varchar(5)");一前一后干嘛要用一个括号啊?把括号去掉......
------解决方案--------------------创建语句少了一个右括号
------解决方案--------------------string SQL =("CREATE TABLE a (Id int NOT NULL ," + "Name varchar (30)," + "Subbranch varchar(30)," + "ErrorCode varchar(5)");
==》
string SQL =("CREATE TABLE a (Id int NOT NULL ," + "Name varchar (30)," + "Subbranch varchar(30)," + "ErrorCode varchar(5))");