none
Oledb, Oracle and wrong character conversion on .net 2.0 RRS feed

  • Question

  • I have troubles on porting c# code from .net 1.1 to .net 2.0.


    I use OleDb to work with Oracle (I have 10 R2), and I noticed that special characters  (è, ü, ä, ...)  that starts from OleDbCommand arrive in Oracle as "¿". All of these characters are converted to  "¿".

    And if I directly (from an Oracle shell) set these characters into Oracle fields, all of them are rendered into .Net as "#".

    I have no problem with .net 1.1.

     

    This happen if I try to issue an "UPDATE" command with these characters, but it also happen if I try to use some of these characters into a "WHERE" clause.

     

    Anybody has any idea about what's wrong?...

    Monday, November 5, 2007 1:40 PM

All replies

  • I've just finished a test on both Instant Client and Standard Client.
    The problem is only on InstantClient, so may be ther is something related to character set and national language support.

    In my standrd client I have into Windows registry NLS_LANG=ITALIAN_ITALY.WE8MSWIN1252.

    I've also tried altering session into code setting:
    NLS_TERRITORY = 'ITALY'
    NLS_LANGUAGE = 'ITALIAN'

    But nothing is changed and the problem with instant client persists.

    Here is the code:

    OleDbConnection oleDbConnection1=new OleDbConnection();
    oleDbConnection1.ConnectionString = "Provider=MSDAORA;Data Source=franz;Persist Security Info=True;Password=avs;User ID=ti_esibiti_dc";
    oleDbConnection1.Open();

    //altering session
    StringBuilder strSql = new StringBuilder();
    strSql.Append("ALTER SESSION SET NLS_TERRITORY = 'ITALY'");
    OleDbCommand command = new OleDbCommand(strSql.ToString(), oleDbConnection1);

    command.ExecuteNonQuery();
    strSql = new StringBuilder();
    strSql.Append("ALTER SESSION SET NLS_LANGUAGE = 'ITALIAN'");
    command = new OleDbCommand(strSql.ToString(), oleDbConnection1);
    command.ExecuteNonQuery();

    command = new OleDbCommand("SELECT COUNT(*) FROM ic_view_qry_es_esibiti WHERE archiviato='Sì'", oleDbConnection1);
    dataReader = command.ExecuteReader();
    dataReader.Read();
    string test = dataReader[0].ToString();
    MessageBox.Show(test);

     

    Wednesday, November 7, 2007 3:49 PM