简体   繁体   中英

Problem with saving chinese character into oracle using NHibernate

I am trying to save chinese character into oracle DB using Nhibernate thru C# and the character saved always end up with some rubbish character.

I have done the following:

  1. Hbm mapping for the field is declared as type AnsiString and column type as sql-type="nvarchar". Have also tried String and nvarchar2 too.
  2. Database column data type is NVARCHAR2.
  3. Registry, environment variable and database charset NLS_LANG is set to UTF8.

I am able to read the chinese character input thru sql developer. But when I try to retrieve them (the character display correctly on screen) and attempt to save them back into the database without any changes, the data saved became " ".

Anyone have any clue what have I miss out here?

I would check what the data really is on the .NET side. Don't trust what's displayed on a console - look at the UTF-16 code points.

See my debugging unicode article for the general approach.

I seem to remember having some problems in Oracle before which were only fixed by setting the database encoding and then rebuilding the database - I couldn't apply it to an existing one. However, the details are in the dim and distant past...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM