473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Cannot display Chinese data from database

Some chinese characters data (in Big5 encoding) is stored in database.
I tried to display the data in an aspx but the characters cannot display
correctly.
I tried anything I think is related:
- Setting the charset, codepage of the page
- changed the responseEncoding in web.config to Big5
- hardcoded Response.ContentEncoding to 950 (codepage of Big5)
- Change the file encoding to Big5 (in save option)
None of them work.

For the same data, it can displayed correctly in my classic asp.

Code (.NET)
private void Page_Load(object sender, System.EventArgs e)
{
SqlConnection connection = new
SqlConnection(ConfigurationSettings.AppSettings["NewsDB"]);
SqlCommand command = new SqlCommand();
command.Connection = connection;
command.CommandText = "SELECT Newsid, StoryDate, StoryTime, Headline
FROM tblLatestHeader";
command.CommandType = CommandType.Text;

SqlDataReader dataReader;
connection.Open();
dataReader = command.ExecuteReader();
string html = "";
while (dataReader.Read())
{
html += dataReader[3].ToString();
}
connection.Close();
Label1.Text = html;
Label2.Text = "ä½*好嗎"; // this is chinese character which can display
correctly
}
Work in classic asp:
<%
Set connection = Server.CreateObject("ADODB.Connection")
connection.ConnectionString = "Provider=sqloledb;Data Source=MyDB;Initial
Catalog=NewsDB;User Id=sa;Password=fakepwd;"
connection.open
Set rs = connection.execute("SELECT Newsid, StoryDate, StoryTime, Headline
FROM tblLatestHeader")

While Not rs.eof
response.write rs("Headline") & "<br>"
rs.movenext
wend
%>

Nov 25 '05 #1
1 3084
Jason Chan wrote:
Some chinese characters data (in Big5 encoding) is stored in database.
I tried to display the data in an aspx but the characters cannot
display correctly.
I tried anything I think is related:
- Setting the charset, codepage of the page
The Codepage directive in ASP.NET 2.0 is the same as reponseEncoding in
web.config.
- changed the responseEncoding in web.config to Big5
- hardcoded Response.ContentEncoding to 950 (codepage of Big5)
And these are identical as well (the latter, like Codepage, works at
the page level though).
- Change the file encoding to Big5 (in save option)
That's only relevant at buildtime.
None of them work.

For the same data, it can displayed correctly in my classic asp.

Code (.NET)
private void Page_Load(object sender, System.EventArgs e)
{
SqlConnection connection = new
SqlConnection(ConfigurationSettings.AppSettings["NewsDB"]);
SqlCommand command = new SqlCommand();
command.Connection = connection;
command.CommandText = "SELECT Newsid, StoryDate, StoryTime,
Headline FROM tblLatestHeader";
command.CommandType = CommandType.Text;

SqlDataReader dataReader;
connection.Open();
dataReader = command.ExecuteReader();
string html = "";
while (dataReader.Read())
{
html += dataReader[3].ToString();
}
connection.Close();
Label1.Text = html;
Label2.Text = "ä½*好嗎"; // this is chinese character which
can display correctly
}


If your hardcoded sample text is displayed correctly, there's quite
likely a problem with your ADO.NET provider. Are the correct characters
displayed when you debug your code right after retrieving strings from
the database?

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 25 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Scott Vercuski | last post by:
Hello All, I'm having a problem saving/displaying multiple lanaguages on an ASP page. Here's the general problem I'm having. I have an admin area of a website that allows a user to enter items...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
1
by: Daman | last post by:
Hi, I am currently facing difficulty displaying chinese, japanese, russian etc. characters. I am using VB 6 and ADO to query the DB2 Version 7.2 unicode database (UTF-8). The resultset that...
3
by: Tom | last post by:
Hi, I built a aspx web page which the charset is UTF-8. I need to present the same Chinese content to both Traditional and Simplified Chinese. However, it shows error code for UTF-8, Big 5 or...
7
by: c.verma | last post by:
I have a web application. There is a page which has a datagrid on it.The datagrid displays the data that comes from SAP. SAP sends the chinese characters to this grid. Before I display CHinese...
1
by: Jason Chan | last post by:
I have an asp to display data in database, the data is in big5 encoding (chinese characters) I haven't specify the codepage in the asp and placed the file into 2 machine. When I browse the file...
12
by: Steven Nagy | last post by:
Hi all, I have to do a website in chinese! Basically I just need to know how to output chinese characters. I am assuming its very easy, but have never done it before. I can however do simple...
0
by: kennymce | last post by:
Hi, I'm having trouble localizing my Oracle 9.2 / ASP web application for our Chinese-speaking users. My Oracle 9.2 Database has NLS_NCHAR_CHARACTERSET set to AL16UTF16. I've set up a test...
3
by: Raymond Chiu | last post by:
Dear All, I have posted my question as below. But no answers, hope it can found here. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.