Solved

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

Posted on 2001-06-28
8
218 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
 
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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now