470,631 Members | 1,513 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,631 developers. It's quick & easy.

Cannot "Insert" Chinese Char

hao
Hi, all

When I use ASP to insert an record to a database, I got
some errors and can not insert any value with Chinese Char.
The only way I can do that is use "rst1.Addnew...rst1.update".
Anyone know why?
thx

hao
Nov 17 '05 #1
4 1933
How about posting those errors you were getting? We're not psychic...

Jerry

"hao" <ph******@hotmail.com> wrote in message
news:eR**************@TK2MSFTNGP09.phx.gbl...
Hi, all

When I use ASP to insert an record to a database, I got
some errors and can not insert any value with Chinese Char.
The only way I can do that is use "rst1.Addnew...rst1.update".
Anyone know why?
thx

hao

Nov 17 '05 #2
hao
Hi Jerry,

If I use "INSERT INTO ...", the error message is :
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] Syntax error in string in query
expression '''. /oa/send.asp, line 199
If I use "response.write" to track the sql string, I found the string was
terminated by the first of the Chinese Char(no Chinese Char can be read)
like this:

The Original SQL string:
INSERT INTO Table1(Field1, Field 2) VALUE('" & FieldValue1 & "', '" &
MyChineseWords & "')"

I got this result:
INSERT INTO Table1(Field1, Field 2) VALUE('abc', '

which the second field is my Chinese Char. No idea why the string
terminated.
If I use "rs.AddNew...." no error message and only a null value saved in the
table. I use "response.write" to
track the value before save to the table, it's still empty.

Lokks like the value MyChineseWords has some symbol and the system think
it's the end of string. I get MyChineseWords from a text form area that
input by user. There is no problem which English Charactor, only in Chinese.
hao

"Jerry III" <je******@hotmail.com> wrote in message
news:Ob**************@tk2msftngp13.phx.gbl...
How about posting those errors you were getting? We're not psychic...

Jerry

"hao" <ph******@hotmail.com> wrote in message
news:eR**************@TK2MSFTNGP09.phx.gbl...
Hi, all

When I use ASP to insert an record to a database, I got
some errors and can not insert any value with Chinese Char.
The only way I can do that is use "rst1.Addnew...rst1.update".
Anyone know why?
thx

hao


Nov 17 '05 #3
hao
The database I used is Access and I know if I use SQL Server, I should add a
'N' before it
to indicate the unicode. But I do not know how to do in Access. Seems the
'N' does not work
in Access.
hao

"Jerry III" <je******@hotmail.com> wrote in message
news:Ob**************@tk2msftngp13.phx.gbl...
How about posting those errors you were getting? We're not psychic...

Jerry

"hao" <ph******@hotmail.com> wrote in message
news:eR**************@TK2MSFTNGP09.phx.gbl...
Hi, all

When I use ASP to insert an record to a database, I got
some errors and can not insert any value with Chinese Char.
The only way I can do that is use "rst1.Addnew...rst1.update".
Anyone know why?
thx

hao


Nov 17 '05 #4
I've never worked with Access, so I'm not sure if it even supports Unicode
strings but my suggestion would be to use Command object and add your
strings as parameters, like this (I suppose the space between Field and 2
and using VALUE instead of VALUES were just typos in your other post):

dbCmd.CommandText = "INSERT INTO Table1(Field1, Field2) VALUES(?, ?)";

dbCmd.Parameters.Add("@Field1", FieldValue1);
dbCmd.Parameters.Add("@Field2", YourChineseWords);

dbCmd.ExecuteNonQuery();

If that doesn't work then Access doesn't support Unicode as it is. In that
case you might have to encode your Unicode strings to UTF-8 before inserting
and remembering to decode them when reading.

Jerry

"hao" <ph******@hotmail.com> wrote in message
news:eJ**************@TK2MSFTNGP10.phx.gbl...
The database I used is Access and I know if I use SQL Server, I should add a 'N' before it
to indicate the unicode. But I do not know how to do in Access. Seems the
'N' does not work
in Access.
hao

"Jerry III" <je******@hotmail.com> wrote in message
news:Ob**************@tk2msftngp13.phx.gbl...
How about posting those errors you were getting? We're not psychic...

Jerry

"hao" <ph******@hotmail.com> wrote in message
news:eR**************@TK2MSFTNGP09.phx.gbl...
Hi, all

When I use ASP to insert an record to a database, I got
some errors and can not insert any value with Chinese Char.
The only way I can do that is use "rst1.Addnew...rst1.update".
Anyone know why?
thx

hao



Nov 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

20 posts views Thread by Mark Harrison | last post: by
9 posts views Thread by Guy Cohen | last post: by
5 posts views Thread by Eric Lilja | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.