I get a error that a query on a mysql database has a wrong syntax. The code should check if a string {Rfid} is present in a Tags database and if not create it. The exception is caused in the first MySqlcmd.CommandText But i dont see it, they're normal mysql verbs, the only speciality perhaps might be that Rfid can contain spaces, but i fail to see why that would give a problem.
OpenConnection(); //a function to connect, no problems here.
MySqlDataReader reader;
MySqlcmd.CommandText = $"SELECT * FROM 'Tags' WHERE 'UHFRFID'=\"'{Rfid}'\" LIMIT 1;";
reader = MySqlcmd.ExecuteReader(); // >> crashes
//create a new tag in table, if its unknown.
if (!reader.HasRows)
{
try
{
MySqlcmd.CommandText = $"INSERT INTO `Tags` (`TagId`, `UHFRFID`, `Gate1`) VALUES(NULL,\"'{Rfid}'\", NULL);";
MySqlcmd.CommandType = System.Data.CommandType.Text;
MySqlcmd.ExecuteNonQuery();
}
catch
{ }
The MySQL error i get is:
MySql.Data.MySqlClient.MySqlException: '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 ''Tags' WHERE 'UHFRFID'='tag 13 00000' LIMIT 1' at line 1'