[Follow-ups trimmed to microsoft.publi c.data.ado]
On 10 Oct 2003 05:31:42 -0700,
sv*******@neo.r r.com (Scott Vercuski)
wrote:
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 in multiple
languages. EX:
NAME LANGUAGE
Trade Show English
商业展览 Chinese
Торговая
выставка Russian
When I store and display the chinese and Russian text I'm using an
update statement as follows.
UPDATE TABLE SET NAME =
N'Торговая
выставка' WHERE LANG =
'RU'
When I read that text out of the database and try to display it, it
just comes up as garbage. If I change my browser encoding to Unicode
(UTF-8) it still comes up as garbage. My question is, how can I get
multiple languages to display on one page?
Firstly, I'm assuming you have your character string columns in your
database as type NVARCHAR, so that they can accommodate Unicode strings.
Next, you should be running on Windows 2000 or XP, so that you are using
IIS 5.0 or higher. You can do this on NT4 with IIS 4.0, but there are
more hoops to jump - it's just not worth it.
When retrieving date from the database to display on the ASP page, you
need to set the CodePage and the CharSet, as follows (example is UTF-8):
<%@ language="vbscr ipt" codepage=65001 %>
<% Response.CharSe t = "UTF-8" %>
This allows data pulled from the database to be correctly encoded as
UTF-8 on output. Alternatively, if you use Server.HTMLEnco de it will
give you HTML encoded versions, like in you example text above (but of
course, your page download size will increase).
For saving your data back to the database, which I presume is SQL Server
given the list of groups you cross-posted to, write a stored procedure
to do the work and use the Parameters collection of the ADO Command
object to set the values. Specify adVarWChar as data type.
Set cmd = Server.CreateOb ject("ADODB.Com mand")
Set cmd.ActiveConne ction = db_conn
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "your_stored_pr oc"
Set params = cmd.Parameters
params.Append cmd.CreateParam eter(, adVarWChar, adParamInput, _
20, fldTitle)
params.Append cmd.CreateParam eter(, adVarWChar, adParamInput, _
60, fldFirstName)
params.Append cmd.CreateParam eter(, adVarWChar, adParamInput, _
60, fldLastName)
params.Append cmd.CreateParam eter(, adDate, adParamInput, _
, fldReturn_Date)
cmd.Execute , , adCmdStoredProc + adExecuteNoReco rds
Works for me.
regards,
Ross.
--
Ross McKay, WebAware Pty Ltd
"Words can only hurt if you try to read them. Don't play their game" - Zoolander