C# MySQL Syntax Error while attempting to insert to table

0

I have a table named 'accounts' with a column called 'Rank' in my MySQL database. 'Rank' is a Length 2 INT type column.

My code for running my MySQL command is:

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

However, when I attempt to run it I get this error:

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

Can anyone point out what is wrong with my syntax?

c#
mysql
asked on Stack Overflow Mar 4, 2019 by vxern • edited Mar 4, 2019 by Symon

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0