我现在正在制作一个 ASP.NET 网站。在 Global.asax 中,如果某些表不存在,我有代码用于初始化它们。代码的 init blog_post 和 booking_dates 部分正确执行并创建表,但 init image_info 没有。它们非常相似,我找不到 MySQL 语法有什么问题。
错误信息:
您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的 ''description' TEXT, PRIMARY KEY(id))' 附近使用正确的语法
//init blog_post
using (MySqlCommand cmd = new MySqlCommand("CREATE TABLE IF NOT EXISTS `blog_post` (" +
"`id` INT AUTO_INCREMENT," +
"`header` VARCHAR(255)," +
"`bbcode` TEXT," +
"`author` VARCHAR(255)," +
"`time_posted` DATETIME, " +
"PRIMARY KEY(id));", con))
{
cmd.ExecuteNonQuery();
cmd.Dispose();
}
//init booked_dates
using (MySqlCommand cmd = new MySqlCommand("CREATE TABLE IF NOT EXISTS `booked_dates` (" +
"`id` INT AUTO_INCREMENT," +
"`author` VARCHAR(255)," +
"`start_time` DATETIME," +
"`end_time` DATETIME," +
"`time_booked` DATETIME, " +
"PRIMARY KEY(id));", con))
{
cmd.ExecuteNonQuery();
cmd.Dispose();
}
//init image_info
using (MySqlCommand cmd = new MySqlCommand("CREATE TABLE IF NOT EXISTS `image_info` (" +
"`id` INT AUTO_INCREMENT," +
"`author` VARCHAR(255)," +
"`file_name` TEXT," +
"`title` TEXT," +
"`album` TEXT, " +
"'description' TEXT, " +
"PRIMARY KEY(id));", con))
{
cmd.ExecuteNonQuery();
cmd.Dispose();
}
提前感谢您的帮助!