A few years have not been used MySQL data, today in the use of C # access to the MySQL database is a small episode.
Error message:
You have a error in your SQL syntax; Check the manual-corresponds to your MySQL server version for the right syntax-use???
Of course, the error message is clearly explained by the syntax error of SQL.
However, my SQL statement was select COUNT (*) from TableName, no errors were found, and then one-step debugging was performed, and the SQL statements executed from the code were pasted into MySQL during debugging, and the results were successfully passed.
Given previous programming experience, the most likely error here is that my SQL statement contains the MySQL keyword, and then look back at the SQL statement, the original statement in the statement (select COUNT (*) from) must be no problem, the problem is in my own writing TableName , found that TableName contain Chinese characters, and then Baidu, found that the character encoding inconsistent (??? In fact, the Chinese characters are not shown), so change the MySQL installation directory under the My.ini file, the file default-character-set=latin1 changed to Default-character-set=utf8 (two places), After restarting the MySQL service, run the program again, problem solving
C # Mysql You have a error in your SQL syntax; Check the manual-corresponds to your MySQL server version for the right syntax-use????