How to solve Chinese garbled characters after the Godaddy database tutorial
1. Open the backed up SQL text in notepad to ensure that the data in the file is properly displayed.
2. view the storage format of this text, generally ANSI (Chinese generally gbk or gb2312) and UTF-8.
3. If the file storage format is ANSI, add the following statements at the top of the SQL file:
/*! 40101 set names gbk */;
If the file storage format is UTF-8, add the following statement at the top of the SQL file:
/*! 40101 set names utf8 */;
4. Save and use the modified SQL file to restore the mysql tutorial database.
My MYSQL backup files are too large, and over 300 M, UltraEdit, and EditPlus are difficult to handle. The results are handled by using WinHex to directly modify the SQL file header.
Finally, I started to write the code. I wrote a test code on the page. The method is the same as that used for SQL Server database or access database. There is no difference.
Mssql server accessk garbled characters
Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Web;
Using System. Web. UI;
Using System. Web. UI. WebControls;
Using System. Data. OleDb;
Using System. Data;
Using MySql. Data. MySqlClient;
Namespace s
{
Public partial class _ Default: System. Web. UI. Page
{
/// <Summary>
/// Wukong note: In the following code, I marked the server address and database name as Chinese. You can modify the code as needed.
/// Wukong's blog www.7es.cn
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "e"> </param>
Protected void Page_Load (object sender, EventArgs e)
{
// Wukong's blog www.zhutiai.com
MySqlConnection conn = new MySqlConnection ("Server = Server address; Port = 3306; Database = Database name; Uid = username; Pwd = 'Password ';");
Conn. Open ();
MySqlCommand cmd = new MySqlCommand ("select * from table name", conn );
MySqlDataReader dr = cmd. ExecuteReader ();
If (dr. Read ())
{
Response. Write (dr ["field name"]. ToString ());
}
Dr. Close ();
Dr. Dispose ();
Cmd. Dispose ();
Response. Write ("<br> end ");
}
}
}