Solved

Insert chinese ( utf-8 charset ) into MS SQL server

Posted on 2006-06-28
4
6,186 Views
Last Modified: 2011-09-12
Does anyone of Experts here know how to insert chinese character (utf-8 charset) into MS SQL Server 2000?

The field are of nvarchar, whenever i attempt to insert, it shows question marks ?????????

It works if i apply either

  server.htmlEncode()

or
   
 Function c2u(CnText)
      For zzzz = 1 to Len(CnText)
        c = Mid(CnText, zzzz, 1)
        c2u = c2u & "&#x" & Hex(AscW(c)) & ";"
      next
    End Function

However the length of the field are fixed and the result will took more spaces
For instance,
请选择   ( 3 chinese characters )
will consume up to 24 nvarchar, thus this is not viable

On each of the asp page

<%@ CodePage = 65001 %>
<%
Response.expires = 0
Response.expiresabsolute = Now() - 1
Response.addHeader "pragma", "no-cache"
Response.addHeader "cache-control", "private"
Response.addHeader "cache-control", "no-cache"
Response.addHeader "cache-control", "no-store"
Response.CacheControl = "no-cache"
Response.CharSet = "utf-8"
%>
 :
 :
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

I have something like this.

Thank you for the helps

Regards
Kelvin
0
Comment
Question by:kelvinwkw
  • 2
4 Comments
 
LVL 21

Expert Comment

by:ap_sajith
ID: 17000559
Try removing the codepage attribute. Also, are you getting the jumbled characters on your browser or in you query analyzer.

Cheers!
0
 
LVL 6

Accepted Solution

by:
darkeryu earned 500 total points
ID: 17002447
hi:

i have this problem before...
you need insert the sql with

insert into table(fd1,fd2) values(N'val1',N'val2')

then you can response correctlly..

thanks
0
 
LVL 11

Author Comment

by:kelvinwkw
ID: 17006359
@ap_sajith  
after i remove the codepage attribute i still get the ??????? instead of chinese characters

@darkeryu
Im using a store procedure for that.

given that
@username nvarchar(30)
@password nvarchar(30)
@email varchar(100)

user nvarchar(30)
pass nvarchar(30)
email varchar(100)

select @checkExist = count(*) from login where username = @username
if @checkExist = 0
begin
      -- if username does not exist
      insert into login(user, pass, email) values(@username, @password, @email)
      select 10000 as msg
      return
end

How am i suppose to dealing with it.

0
 
LVL 6

Expert Comment

by:darkeryu
ID: 17006398
hi:

you can modify sql statement

insert into login(user, pass, email) values(N@username, N@password, N@email)
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
EOF BOF error classic asp 8 46
Classic ASP, Search Recordset on pick list change 1 65
IP API - need data... 4 23
Select only the top record in a left join 13 34
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question