Urgent: Help to set Encoding for OracleDataReader

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I'd like to set Encoding to OracleDataReader/OracleCommand or relative class (just like StreamReader class constructor). Is that possible

Thank
Peter
 
Peter said:
I'd like to set Encoding to OracleDataReader/OracleCommand or
relative class (just like StreamReader class constructor). Is that
possible?

The driver should provide the appropriate encoding so that when you
call GetString, it returns the correct Unicode data however the
database has been set up. I don't see where an encoding would come into
it.
 
Thanks first

But, it is not give me a correct data. The oracle DB is 8i something, it is use ISO-8859 (+). But the data in varchar2 have UTF8 encoding. With other tools, if I set environment

NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P

It works fine (garbage in, garbage out). DB does not do encoding and decoding since client and server are in the same code page I think

But C#, does not and set this NLS_LANG does not affect the result.

Is there something I can do in connection string to tell driver which lauguage encoding I want? Or can I configure the driver (how to tell which driver I used for managed code?

Thanks.
 
Peter said:
But, it is not give me a correct data. The oracle DB is 8i something,
it is use ISO-8859 (+). But the data in varchar2 have UTF8 encoding.
With other tools, if I set environment:

What do you mean by "have UTF8 encoding"? varchar2 columns are (I
believe) Unicode columns fundamentally. How they are stored in the
database itself should have no bearing on what you see when you
retrieve the data.
NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1

It works fine (garbage in, garbage out). DB does not do encoding and
decoding since client and server are in the same code page I think.

Either the database or the driver *should* be doing all the encoding
and decoding. There should be nothing to do on the client side except
perhaps specifying something on the connection string.
But C#, does not and set this NLS_LANG does not affect the result.

Is there something I can do in connection string to tell driver which
lauguage encoding I want? Or can I configure the driver (how to tell
which driver I used for managed code?)

There may be something you can configure in the connection string -
which driver are you using, and does the documentation specify
anything?
 
Thanks first. See below

----- Jon Skeet [C# MVP] wrote: ----

Peter said:
But, it is not give me a correct data. The oracle DB is 8i something
it is use ISO-8859 (+). But the data in varchar2 have UTF8 encoding
With other tools, if I set environment

What do you mean by "have UTF8 encoding"? varchar2 columns are (I
believe) Unicode columns fundamentally. How they are stored in the
database itself should have no bearing on what you see when you
retrieve the data
Peter
The DB is ISO. the old DB client is configured as ISO only. So, there is no conversion happened between read and write from and to DB in the old way. If I passed UTF8 string to the old DB client, then the data in columns will be UTF8 encoding.
Now, the new DB client or provider is not ISO client, so there is conversion happened (1) I do not want it happen because not all data in the target columns are UTF8 encoded, there are other encoding also upon business logic (value in other columnn in DB). (2) It does the wrong decoding (I guess conversion ISO to UTF8) even if the data in column is UTF8.
NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P
decoding since client and server are in the same code page I think

Either the database or the driver *should* be doing all the encoding
and decoding. There should be nothing to do on the client side except
perhaps specifying something on the connection string

Peter
But if client side can not programmably set required decoding/encoding, sometime, it will be hard to migration or in my situation. The data in column have mixes encoding, even different DB use different encoding, tons of millions rows in each DB or tables of DB
But C#, does not and set this NLS_LANG does not affect the result.
lauguage encoding I want? Or can I configure the driver (how to tel
which driver I used for managed code?

There may be something you can configure in the connection string -
which driver are you using, and does the documentation specify
anything

Peter
I have oracle 8i and 9i thick client and only thing I know is to set environment varaible, which only works for other tools, but not .NET OracleClient
 
Back
Top