469,578 Members | 1,810 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Saving Unicode in SQL using ASP

I have an asp application that should allow the user to enter Unicode
characters.

The characters appear correctly in the browser.
When saved in sql 2000 thought they are converted to question marks
etc.
When I enter the characters directly in SQL (using enterprise manager),
they appear correctly in sql as well as in the browser when the asp
page retrieves them.
As soon as I hit save they get overwritten in sql incorrectly.

Any help would be appreciated.
Thanks

Aug 18 '05 #1
6 6178
What does your UPDATE / INSERT statement look like? Are you prefixing your
strings with N prefix to denote Unicode or, better yet, using a Command
object with the correct parameter type?

<hi***@cambridgesoft.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
I have an asp application that should allow the user to enter Unicode
characters.

The characters appear correctly in the browser.
When saved in sql 2000 thought they are converted to question marks
etc.
When I enter the characters directly in SQL (using enterprise manager),
they appear correctly in sql as well as in the browser when the asp
page retrieves them.
As soon as I hit save they get overwritten in sql incorrectly.

Any help would be appreciated.
Thanks

Aug 18 '05 #2
I didn't know that my UPDATE/INSERT should look any different. Can you
give an example of what they should look like?

Thanks

Aug 18 '05 #3
INSERT table_name(column_name) SELECT N''

You need to determine if the unicode character is getting lost between ASP
pages or between the second ASP page and the call to the
update/insert/stored procedure statement.

A very basic and common debugging technique is to response.write sql instead
of conn.execute sql.

A

"hilio" <hi***@cambridgesoft.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
I didn't know that my UPDATE/INSERT should look any different. Can you
give an example of what they should look like?

Thanks

Aug 18 '05 #4
Aaron, thanks for the suggestion. I tried response.write and it
displayed different characters, not the characters that are entered by
the user. Would this indicate that the web server is not interpreting
the characters correctly?

Aug 18 '05 #5
first make sure that you are using a character set in the browser that
supports the characters. Then make sure that you are using a code page in
ASP that supports them as well. Simplest way is to use UTF-8

in ASP script
Session.Codepage=65001

then send to browser:
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">

Now you should see the same characters back when you write the SQL statement
back.

Now you need to get the data into the database. If you have SQLServer set to
a collation that supports your characterset then it should work now. If not,
you will need to use NCHAR or NTEXT columns. Either use a parameterized
command object or when building dynamic SQL prefix the data string with "N"
to tell SQLServer that the data is unicode.

--
--Mark Schupp
"hilio" <hi***@cambridgesoft.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
Aaron, thanks for the suggestion. I tried response.write and it
displayed different characters, not the characters that are entered by
the user. Would this indicate that the web server is not interpreting
the characters correctly?

Aug 18 '05 #6
Thank you both for the replies.
I implemented your suggestions and it now works. I learned that SQL
requires the N prefix for updates and inserts of UNICODE data.

Thank you all

Aug 19 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

19 posts views Thread by Svennglenn | last post: by
7 posts views Thread by Philipp Lenssen | last post: by
4 posts views Thread by Andrew Inwards | last post: by
3 posts views Thread by andy_ro | last post: by
2 posts views Thread by perspolis | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.