Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
512 views
in Technique[技术] by (71.8m points)

c# 3.0 - when insert persian character in oracle db i see the question mark

I use the oracle with c#, i insert embedded in c# code , and my column(NVARCHAR2) and use N 'string'. when insert in my machine that's correct and OK, but when run my app in sever (another machine) I see the question mark(????).

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

When you say you run on the server, you mean through SQL*Plus?

First thing to check is what actual character is being stored - use the DUMP function to check this:

Oracle Dump Function

This will tell you what is actually stored. If the chain between your client app and Oracle server is not appropriate you might get character set conversion occurring.

Assuming the correct character is being saved, what you then see on the server / sqlplus is character conversion on display. I.e. Oracle is "serving up" the character correctly, but the display is not handling it as you expect. To fix this, you need to set the NLS_LANG environment variable to the correct character set.

e.g., in a recent project the default:

set NLS_LANG=AMERICAN_AMERICA.US7ASCII

then query some data gave:

NAME
-----------------------------------
MS ELLIE MARTALL

But:

set NLS_LANG=AMERICAN_AMERICA.US8PC437

Then running the query gave:

NAME
-----------------------------------
MS éLLIE MARTALL

And also:

set NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P15

gave:

NAME
-----------------------------------
MS ╔LLIE MARTALL

The key thing here is the actual data is the same, it's the way that data is being presented on your display is what differs, and that behavior can be controlled by NLS_LANG.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...