尝试插入表时C#MySQL语法错误

时间:2019-03-04 20:22:43

标签: c# mysql

我的MySQL数据库中有一个名为“ accounts”的表,其中有一列“ Rank”。 “等级”是“长度2整数”类型的列。

我运行MySQL命令的代码是:

Command = CreateQuery();
Command.CommandText = "INSERT INTO accounts ([Rank]) VALUES (0)";
Command.ExecuteNonQuery();

但是,当我尝试运行它时,出现此错误:

MySql.Data.MySqlClient.MySqlException (0x80004005): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Rank) VALUES (0)' at line 1
   at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
   at MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId)
   at MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32& affectedRows, Int64& insertedId)
   at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
   at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()
   at (***) in (***)Database.cs:line 113

有人可以指出我的语法有什么问题吗?

0 个答案:

没有答案