This article mainly describes the actual solution for operating MySQL Chinese garbled characters in C # And the misunderstanding that is easy to get into in actual operations. The following describes the specific solution, if you are interested, you can click the following articles to view them.
Misunderstanding:
In the past few days, the optional encoding methods for searching online resources are: gb2312, gbk, and utf8 support dual-byte encoding types. This is not the case in actual experiments.
A. We all want to use utf8, but UTF8 is not ideal for Chinese processing, and Select, Update, and Insert are garbled;
B. the gbk character set is much larger than the gb2312 character set. It is the second preferred character set. However, after the Server/Database is set to the GBK character set, the connection in the program fails (not support), not to mention the operation;
Final Solution:
1. gb2312 Encoding
2. Set the default encoding in the my. ini file.
Add or modify default_charater_set = gb2312 in the [optimal combination of MySQL (and PHP)] and [optimal combination of MySQL (and PHP) d] configuration segments.
3. When creating a database, use gb2312 encoding.
4. When creating a table, use gb2312 encoding and gb2312_chines_ci for Collation (gb2312_bin is not tested)
5. Set the encoding for specific fields that need to store Chinese characters using gb2312 and gb2312_chines_ci for Collation (gb2312_bin is not tested)
Improvement:
If you do need to store gbk encoded characters, run set names gbk after the connection is successful.
There are a total of related topics 100
The above content is an introduction to the solution for C # To operate MySQL with Chinese garbled characters. I hope you will gain some benefits.
The above content is the description of the solution for operating MySQL in C # With Chinese garbled characters. I hope it will help you in this regard.