Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

sql server manipulation with chinese

Hi,

I am having problems with working with asp.net and sql server 2000. If

I use utf-8 encoding, then the characters display correctly in asp.net

pages. But it will stored as strange characters (~7~) in db. vice,

versa, if I change the encoding to Chinese Simplified (HZ), then the

characters saves ok from asp.net page to db. But when I retrieve the

characters from db back to display in asp.net page, then now I am

getting (~7~) on the asp.net page. For the collation setting on sql

server 2000, I tried both the default setting and PRC_BIN, nothing is

working. Please help.

Thanks.
[687 byte] By [mmingfeilam] at [2007-11-11 8:19:24]
# 1 Re: sql server manipulation with chinese
See if this helps: http://www.dotnetjunkies.com/Tutorial/17E26271-E212-4248-965F-4B33D2EDD38B.dcik

What is the data type of the SQL Server column? I would think that if you use an nvarchar column and utf-8 encoding on the page, it should just work.
Phil Weber at 2007-11-11 23:13:19 >
# 2 Re: sql server manipulation with chinese
Thanks, please see attched for the details.

Sorry for the messiness, but below is my login page:

<%@ Page Language="c#" Codebehind="login.aspx.cs" Culture="zh-CN" Inherits="login2.login" codePage="65001" %>
<%@ Import Namespace="System.Web.Security" %>
<%@ Register TagPrefix="LOG" TagName="Header" Src="UserControl\Header.ascx" %>
<HTML>
<HEAD>
<title>Login Page</title>
<?xml version="1.0" encoding="utf-8" ?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</HEAD>
<body background="images/back_sub.gif">
<form action="Login.aspx" method="post" runat="server">
<font face="Verdana, Arial, Helvetica" size="2">
<table border="0">
<TBODY>
<tr>
<td colSpan="5"><LOG:HEADER id="Header" runat="server"></LOG:HEADER></td>
</tr>
<!--Begin Navigational Buttons-->
<tr>
<td vAlign="top" align="left" rowSpan="5"></td>
<td vAlign="top">
<center><br>
<input id="ReturnUrl" type="hidden" value="/login2/default.aspx" runat="server">
<P><asp:label id="Label1" runat="server">你</asp:label> <FONT face="SimHei"><FONT face="SimSun">
你好</FONT><br>
</FONT>
<br>
<table cellPadding="5" colspan="2">
<tr>
<td width="150"></td>
<td width="310" bgColor="#800000"><font color="#ffffff" size="2"><b>Login</b></font>
</td>
</tr>
<tr>
<td width="150"></td>
<td vAlign="top" bgColor="#f7efde">
<table>
<tr>
<td width="100"><font size="2">Email Address: </font>
</td>
<td><asp:textbox id="UserName" runat="server" width="160"></asp:textbox></td>
</tr>
<tr>
<td><font size="2">Password: </font>
</td>
<td><asp:textbox id="Password" runat="server" width="160" TextMode="Password"></asp:textbox></td>
</tr>
<tr>
<td></td>
<td><asp:checkbox id="Persist" runat="server"></asp:checkbox><font size="2">Remember
Password</font></td>
</tr>
<tr>
<td align="right" colSpan="2"><asp:button id="Button1" onclick="LoginBtn_Click" runat="server" Text=" Login "></asp:button></td>
</tr>
</table>
</td>
</tr>
</table>
<br>
<font size="2">
<asp:hyperlink id="RegisterUser" runat="server" NavigateUrl="Register.aspx">Click Here to Register New Account </asp:hyperlink></font><br>
<br>
<font color="red" size="2"><b>
<asp:label id="Message" runat="server"></asp:label></b></font>
</center>
</font></P></TD></TR></TBODY></TABLE></FONT></form>
</body>
</HTML>
mmingfeilam at 2007-11-11 23:14:19 >