Sunday, March 25, 2012

Cannot read unicode data from SQL Server

Hi all,
I have a SQL Server 2000 running as the database and there
is a table contain some multi-language data, the table
structure is as follow:
CREATE TABLE mytable
(
english nvarchar(255),
japanese nvarchar(255),
chinese nvarchar(255)
)
The chinese column will store traditional chinese
characters while the japanese column will store japanese
character.
I have already imported all the record from an well-
defined Excel file to mytable, and I can read all the
chinese and japanese characters properly from Enterprise
manager and Query Analyzer, however, when I use ADO
recordset to get the data from mytable in the ASP, the
data cannot be shown properly, all the japanese and
chinese data is shown as question marks (ie,"'?").
Here is my ASP Code,
Set dbCon = Server.CreateObject("ADODB.Connection")
dbCon.Open "Provider=SQLOLEDB.1;Persist Security
Info=False;User ID=sa;Initial Catalog=mydatabase;Data
Source=myserver"
Set rs = Server.CreateObject("ADODB.RecordSet")
rs.CursorLocation = 3
rs.CursorType = 3
rs.LockType = 3
rs.ActiveConnection = dbCon
rs.Open "Select * from mytable"
Even though I have changed the charset to "big5" in the
ASP, only chinese character can be shown properly, but not
japanese. I have already try all the charset in my ASP,
but none of them can show the japanese characters properly.
rmk:
1. I am running Traditional Chinese Windows 2k and in the
regional setting, I have set the default locate to
traditional chinese.
2. The collation of the my database is
SQL_Latin1_General_CP1_CI_AS
Is it the collation problem, window OS locate problem,data
type problem or the ASP coding problem ?
Anyone can help me ?
Many thanks
ongMake sure Japanses font is installed.
Do not use charset Big5. You want utf-8
Use the directive <%@. CodePage=65001 %> at the top of your asp page
"ong" <on_g@.sinatown.com> wrote in message
news:011c01c35012$1b1bb560$a001280a@.phx.gbl...
> Hi all,
> I have a SQL Server 2000 running as the database and there
> is a table contain some multi-language data, the table
> structure is as follow:
> CREATE TABLE mytable
> (
> english nvarchar(255),
> japanese nvarchar(255),
> chinese nvarchar(255)
> )
> The chinese column will store traditional chinese
> characters while the japanese column will store japanese
> character.
> I have already imported all the record from an well-
> defined Excel file to mytable, and I can read all the
> chinese and japanese characters properly from Enterprise
> manager and Query Analyzer, however, when I use ADO
> recordset to get the data from mytable in the ASP, the
> data cannot be shown properly, all the japanese and
> chinese data is shown as question marks (ie,"'?").
> Here is my ASP Code,
> Set dbCon = Server.CreateObject("ADODB.Connection")
> dbCon.Open "Provider=SQLOLEDB.1;Persist Security
> Info=False;User ID=sa;Initial Catalog=mydatabase;Data
> Source=myserver"
> Set rs = Server.CreateObject("ADODB.RecordSet")
> rs.CursorLocation = 3
> rs.CursorType = 3
> rs.LockType = 3
> rs.ActiveConnection = dbCon
> rs.Open "Select * from mytable"
>
> Even though I have changed the charset to "big5" in the
> ASP, only chinese character can be shown properly, but not
> japanese. I have already try all the charset in my ASP,
> but none of them can show the japanese characters properly.
> rmk:
> 1. I am running Traditional Chinese Windows 2k and in the
> regional setting, I have set the default locate to
> traditional chinese.
> 2. The collation of the my database is
> SQL_Latin1_General_CP1_CI_AS
>
> Is it the collation problem, window OS locate problem,data
> type problem or the ASP coding problem ?
> Anyone can help me ?
> Many thanks
> ong
>

No comments:

Post a Comment