Skip to main content
Inspiring
January 8, 2007
Answered

Insert Record with Chinese Characters

  • January 8, 2007
  • 4 replies
  • 729 views
When I try to insert a record into a database from a form containing Chinese characters they get garbled and don't insert correctly.

If I manually run an insert query everything works correctly.

I checked that the database fields were type "nvarchar".

Please help!
This topic has been closed for replies.
Correct answer MBaith-XyRqIV
I finally found what the problem was. The page was set with the charset:

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

I needed to set the code page to 936:

<%@LANGUAGE="VBSCRIPT" codepage=936 %>

Now both my custom insert and the Dreamweaver insert record are working.

Now I have a new problem. After the insert I use CDONTS to send an e-mail, but it is also having a problem with the Chinese characters. Anyone know how to send an email using CDONTS (or something else) with Chinese characters?

4 replies

Inspiring
January 10, 2007
OK, to get the email working I set the following on my CDONTS object:

objCDO.MailFormat = 0
objCDO.SetLocaleIDs(65001)

Now the email is sending correctly also.
MBaith-XyRqIVAuthorCorrect answer
Inspiring
January 9, 2007
I finally found what the problem was. The page was set with the charset:

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

I needed to set the code page to 936:

<%@LANGUAGE="VBSCRIPT" codepage=936 %>

Now both my custom insert and the Dreamweaver insert record are working.

Now I have a new problem. After the insert I use CDONTS to send an e-mail, but it is also having a problem with the Chinese characters. Anyone know how to send an email using CDONTS (or something else) with Chinese characters?
Inspiring
January 9, 2007
I just tried my test SQL using ADO on the web page and I got garbage in the database also. So, it looks like it may not be Dreamweaver.

If I run the following in Enterprise Manager everything works correctly, but if I run it on the webpage it doesn't.

INSERT INTO dbo.Table (RequestType) VALUES (N'必填栏目')

Any ideas what this could be?
Inspiring
January 8, 2007
Have you checked the collation for the database?

"MBaith" <webforumsuser@macromedia.com> wrote in message
news:enufq9$9jn$1@forums.macromedia.com...
> When I try to insert a record into a database from a form containing
> Chinese
> characters they get garbled and don't insert correctly.
>
> If I manually run an insert query everything works correctly.
>
> I checked that the database fields were type "nvarchar".
>
> Please help!
>


Inspiring
January 9, 2007
The fields in the table were set to SQL_Latin1_General_CP1_CI_AS. I re-created the table and set them to Chinese_PRC_CI_AS, with the same result.

For example, when I put "必填栏目" into a form and submit it shows up in the database as "±ØÌîÀ¸Ä¿"

After the insert I commented out the redirect and did a "Response.Write Request("FormField")" and it displayed the correct characters, so I know it is getting to the page.

What else should I try?

Thanks!