C # Connection Mysql Chinese garbled problem solving method

Source: Internet
Author: User

Method One
Open the My.ini of the MySQL tutorial installation directory, adding default-character-set= in [client] and [mysqld] respectively gb2312
When you create a new table, select character set and collation as gb2312 and Gb2312_chinese_ci respectively.

Method Two

Use the mysql_query (MySQL *mysql, const char *STMT_STR) to set the character encoding for each query statement:

mysql_query (&mysql, "Set names GBK");

Ensure that each query is based on the GBK encoding of the query, where the following conditions, such as: ' table.column1 ' = The following string is GBK encoding;

Method Three

Mysqlcommand SetFormat = new Mysqlcommand ("Set names gb2312", m_connection);
Setformat.executenonquery ();
Setformat.dispose ();

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.