Solutions for garbled question marks in ASP MySQL

Source: Internet
Author: User

This is because

Database Character Set, table character set, and field character set are all set to: gbk_chinese_ci

Note that stmt = set names 'gbk' in the database connection string must have this sentence.

Below is the ASP link to MySQLCode. Note that there is a GBK later. In this way, the encoding type of the link is specified. Based on your data
Library encoding type. Modify it to your own.

Connectionstring = "driver = {MySQL ODBC 3.51
Driver}; server = myserver; database = MySQL; user = myuser; Password = mypassword; option = 3; stmt = Set
Names 'gbk '"

If you use a higher version of MySQL, this often occurs, and Chinese characters are often garbled; including in PHP.

Reference Method:

Set the font of MySQL.
Add in MySQL. ini

[MySQL]
Default-character-set = gb2312

[Client]
Default-character-set = gb2312

[Mysqld]
Default-character-set = gb2312 // or GBK

After the registration is changed, the contents of the DB. Opt file under these database directories are changed

Default-character-set = gb2312
Default-collation = gb2312_chinese_ci

You can also do this.

Dim drivername, CHS
Drivername = "driver = {MySQL ODBC 3.51
Driver}; server = localhost; database = test; uid = loaer; Pwd = 123456 ;"
Set conn = server. Createobject ("ADODB. Connection ")
Conn. Open drivername

'Execute the following statement before querying
Set CHS = conn. Execute ("set names 'gb2312 '")

'Query database tables

SQL = "select * From tb_commondata"
Set rs = conn. Execute (SQL)

So there will be no garbled characters.

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.