Solved

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

Posted on 2001-06-28
8
227 Views
Last Modified: 2006-11-17
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
Comment
Question by:rblackwell
8 Comments
 
LVL 5

Expert Comment

by:raizon
ID: 6235383
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
 
LVL 15

Accepted Solution

by:
robbert earned 150 total points
ID: 6235541
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
 

Expert Comment

by:globarena
ID: 6237348
hi rblackwell,

Try with  this:


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

0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 20

Expert Comment

by:Silvers5
ID: 6237471
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
 

Author Comment

by:rblackwell
ID: 6239477
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
 
LVL 15

Expert Comment

by:robbert
ID: 6239508
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
 

Author Comment

by:rblackwell
ID: 6239520
There was an extra space after the N - now it works.
Thanks Once Again to my man Robert!
0
 
LVL 15

Expert Comment

by:robbert
ID: 6239648
At least, it works somehow :-)
And thanks, I just posted because you're such a "good" questioner.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
sql to convert to date IF entry is in date format 4 94
SP to delete duplicates 15 73
How to show result of a NULL value at random? 33 57
Adding Row and Cell on a table 14 25
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question