C # Mysql You have a error in your SQL syntax; Check the manual-corresponds to your MySQL server version for the right syntax-use????

Source: Internet
Author: User

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????

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.