MySQL query does not reach the Chinese problem

Source: Internet
Author: User
Tags mysql in mysql query

In the where of the query statement, if you want to query the conditions that contain Chinese, you will never find the value, the feeling is a problem.

Added "Character Set=utf8" in the connection string

I used the entity Framework to connect to MySQL a long time ago, and there was no Chinese garbled problem. This use, the database is UTF8 code, supposedly, also should not garbled, but unfortunately, unexpectedly garbled. Finally, the solution was found: simply add Character Set=utf8 to the connection string in the configuration file

add more:

1. MYSQL: Ensure all the columns are in the UTF8 format.

2. VS2010: When establishing a connection in data server, select Advance, set Chracterset to UTF8, so that when you view and change data in MySQL in VS2010, you will not see a lot of garbled characters because of the mismatch.

 3. Entity Framework: Our page is connected to MySQL using EF, which also needs to be set.

A. Try to establish a connection with a DataSource, and save the connection string in Web. config, as in the previous connection, set CharacterSet to UTF8, which can be checked in Web. config, for example:  < Span style= "Box-sizing:border-box; Color: #666666; font-family: Microsoft Ya-hei, Verdana, ' Ms Song ', song Body, Arial, Helvetica, Sans-serif; line-height:21px; Background-color: #dddddd; " > character Set=utf8 ;d Atabase=map "providername=" MySql.Data.MySqlClient "/>

B. When you create a new EF model, you select the database connection and choose the one that is mentioned in 1, which will ensure that the Web page is displayed and that the changed Chinese can be updated correctly to MySQL.

MySQL query does not reach the Chinese problem

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.