Thursday, March 8, 2012

data mixed up after update

Hi!

I have quite strange problem, that I haven't seen before.

When I use update command:

UPDATE categorys SET banner_valid= '0', section_id= '1', main_cat_default= '0', banner= '', b_link= '', external_text= 'Nākotnes parks ', in_frontpage= '1', name = '100. pants' WHERE (id = 130)

Then the field EXTERNAL_TEXT should have value Nākotnes parks but instead of this it makes it Nakotnes parks.

I changed collation to Latvian and this did not work.

But!!! When I open Enterprise manager and just type in Nākotnes parks and save it then it is ok, but it does not work with Update/add script

Any help or ideas?

I would try changing Asp.net to UTF16, maybe Latvian is only UTF 16. That maybe the reason it works in Enterprise manager and not in your application. SQL Server Unicode is multibyte UTF16 while .NET you have the option of using singlebyte UTF8. Hope this helps.

Kind regards,

Gift Peddie

|||You need to tell SQL Server that you're submitting Unicode text by giving your string the N prefix:
UPDATE categorys
SET banner_valid= '0',section_id= '1', main_cat_default= '0', banner= '', b_link= '',external_text= N'Nākotnes parks ', in_frontpage= '1', name = '100.pants'
WHERE id = 130
|||

SQL Server Unicode is multibyte UTF16


Actually it's not. It's UCS2, which is a fixed-length encoding.

you have the option of using singlebyte UTF8


UTF-8 is a variable-length encoding, so a given character encoded with UTF-8 *may* only require a single byte, or it may require two bytes, or four. It can represent anything that you can store in UCS2 just fine.

No comments:

Post a Comment