Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Insert Record with Chinese Characters

Explorer ,
Jan 08, 2007 Jan 08, 2007

Copy link to clipboard

Copied

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!
TOPICS
Server side applications

Views

628
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Jan 09, 2007 Jan 09, 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) w...

Votes

Translate
LEGEND ,
Jan 08, 2007 Jan 08, 2007

Copy link to clipboard

Copied

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!
>


Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 08, 2007 Jan 08, 2007

Copy link to clipboard

Copied

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!

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 09, 2007 Jan 09, 2007

Copy link to clipboard

Copied

Is it possible to delete and re-create the database using Chinese_PRC_CI_AS
collation from the outset? If so, I would try this and see if you get better
results.

Pat.


"MBaith" <webforumsuser@macromedia.com> wrote in message
news:enun50$hui$1@forums.macromedia.com...
> 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!
>


Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 09, 2007 Jan 09, 2007

Copy link to clipboard

Copied

I tried the following:

Setup a new database with the collation set to Chinese_PRC_CI_AS.
Setup a new user with the language set to Simplified Chinese.
Add the table and set each column to Chinese_PRC_CI_AS.

But, I still get the same thing... Maybe I need to configure something in Dreamweaver? It works if I manually write a SQL statement, but if I use Dreamweaver's "Insert Record" it puts garbage in the database.

Any ideas? I have several forms to do with ~20 fields each, so I would prefer to let Dreamweaver do the inserts.

Thanks!

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 09, 2007 Jan 09, 2007

Copy link to clipboard

Copied

I would ignore Dreamweavers crappy built in behaviours and hand-code the
script. It doesn't appear to be the database that is causing the problem.

Best of luck.


"MBaith" <webforumsuser@macromedia.com> wrote in message
news:eo0r5l$7j2$1@forums.macromedia.com...
>I tried the following:
>
> Setup a new database with the collation set to Chinese_PRC_CI_AS.
> Setup a new user with the language set to Simplified Chinese.
> Add the table and set each column to Chinese_PRC_CI_AS.
>
> But, I still get the same thing... Maybe I need to configure something in
> Dreamweaver? It works if I manually write a SQL statement, but if I use
> Dreamweaver's "Insert Record" it puts garbage in the database.
>
> Any ideas? I have several forms to do with ~20 fields each, so I would
> prefer
> to let Dreamweaver do the inserts.
>
> Thanks!
>


Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 09, 2007 Jan 09, 2007

Copy link to clipboard

Copied

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?

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 09, 2007 Jan 09, 2007

Copy link to clipboard

Copied

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?

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 09, 2007 Jan 09, 2007

Copy link to clipboard

Copied

LATEST
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.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines