C # garbled characters in connection to MySQL (4.0)

Source: Internet
Author: User

When using C # to connect to the MySQL 4.0 database, it is found that the returned value letters and Chinese characters are normal, and only one column returns an exception. Check the database and find that the field is of the following type:

Type varchar

Length 6

Attributes binary not null

In the actual call process, it is found that the returned byte [] type, so the conversion is performed and the problem is solved. The specific conversion is as follows:

Byte [] temp = (byte []) Row ["saleunitcode"];
String temp2 = encoding. utf8.getstring (temp, 0, temp. Length );

 

Record your experiences and witness your youthful Growth

 

 

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.