Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 246
  • Last Modified:

Need to save UniCode characters to SQLdb- How is this done?

I have a password field that gets encrypted characters. In SQL server the field is an nvarchar an it should accept any character, however it does not. Speaking with Nigel in the SQL expert area he has stated;

"What is the field supposed to hold - you only need ntext if the field needs to be more than 4000 chars.
text fields are a lot more difficult to manipulate than chars so should only be used if necessary.The nvarchar field will accept any unicode character - if it is not then there is probably a problem with your interface. The field needs to be handled as unicode everywhere."

I believe he is on to the answer, but i'm not sure I'm sending unicode to the db or more likely the case I'm not accepting them back. How do I save and retrieve Unicode characters (strings) and why is this a problem?

0
rblackwell
Asked:
rblackwell
1 Solution
 
raizonCommented:
I'm not sure if this will work but you can try setting the enctype in the form element (enctype="multipart/form-data").  That is what is required to send non-ascii data via a form.

HTH

Raizon
0
 
robbertCommented:
This works:

INSERT INTO table (nvarchar-field)
VALUES (N'unicode-string')

However, I didn't find a way to make:

objRst.AddNew
objRst("nvarchar-field") = "unicode-string"
objRst.Update

to work, trying variations.

HTH
0
 
globarenaCommented:
hi rblackwell,

Try with  this:


<META http-equiv=Content-Type content="text/html; charset=unicode">

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Michel SakrCommented:
the form should be unicode and the script code page should be set to your character set:

ussian code page:

<%@ Language=VBScript Codepage=1251%>

or

Session.CodePage=1251

(Session.LCID = 1251  'location identifier, used for currency,date etc formats)


these code page links might help:

http://www.microsoft.com/globaldev/reference/WinCP.asp
http://www.microsoft.com/globaldev/win2k/setup/localsupport.asp
http://www.microsoft.com/globaldev/FAQs/Locales.asp
0
 
rblackwellAuthor Commented:
Roberts idea to use "INSERT INTO table (nvarchar-field)
VALUES (N'unicode-string')" seems to be in line with our coding requirments.
The result however is this ->
[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near 'wyi'.
My SQL statement passed to ADO is this ->
SQL=UPDATE Customers SET PassWord = N 'wyi' WHERE Username = 'rblackwell'

The part 'wyi' is the encoded password with non-ascii chars. Why does it not like the SQL statment???
0
 
robbertCommented:
I must admit that the N' (and the codepage) thing is all I know. Also, I grabbed my suggestion from somewhere, and it just worked with ASCII characters, and nXX fields in SQL Server (that's a first achievement as nXX fields can't be addressed, otherwise).
Sorry.
0
 
rblackwellAuthor Commented:
There was an extra space after the N - now it works.
Thanks Once Again to my man Robert!
0
 
robbertCommented:
At least, it works somehow :-)
And thanks, I just posted because you're such a "good" questioner.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now