dotConnect for Oracle Documentation
Devart.Data.Oracle Namespace / OracleConnection Class / Unicode Property
Example

In This Topic
    Unicode Property (OracleConnection)
    In This Topic
    Gets or sets a value indicating whether the UTF16 charset will be used.
    Syntax
    'Declaration
     
    Public Property Unicode As Boolean
    public bool Unicode {get; set;}

    Property Value

    true, if client charset UTF16 is used; false, if default client charset is used. The default value is false.
    Example
    The following two functions demonstrate how to use Unicode property to implement charset-safe string transfer.
    public void UploadString(OracleConnection myConnection)
    {
      myConnection.Unicode = true;
      OracleCommand myCommand = new OracleCommand("INSERT INTO Test.TextBlocks (BlockID, BlockName, BlockContent) VALUES(1,'First',:BlockText)", myConnection);
      myCommand.Parameters.Add("BlockText",OracleDbType.VarChar,50).Value = "Place here some text that requires Unicode support.";
      myConnection.Open();
      try
      {
        Console.WriteLine(myCommand.ExecuteNonQuery()+" rows affected.");
      }
      finally
      {
        myConnection.Close();
      }
    }                                                                                                                                           
    
    public void DownloadString(OracleConnection myConnection)
    {
      myConnection.Unicode = true;
      OracleCommand myCommand = new OracleCommand("SELECT * FROM Test.TextBlocks", myConnection);
      myConnection.Open();
      OracleDataReader myReader = myCommand.ExecuteReader(CommandBehavior.Default);
      try
      {
        while (myReader.Read())
        {
          string myString = (string)myReader["BlockContent"];
          Console.WriteLine(myString);
        }
      }
      finally
      {
        myReader.Close();
        myConnection.Close();
      }
    }
    Public Sub UploadString(ByVal myConnection As OracleConnection)
      myConnection.Unicode = True
      Dim myCommand As New OracleCommand("INSERT INTO Test.TextBlocks (BlockID, BlockName, BlockContent) VALUES(1,'First',:BlockText)", myConnection)
      myCommand.Parameters.Add("BlockText", OracleDbType.VarChar, 50).Value = "Place here some text that requires Unicode support."
      myConnection.Open()
      Try
        Console.WriteLine(String.Concat(myCommand.ExecuteNonQuery(), " rows affected."))
      Finally
        myConnection.Close()
      End Try
    End Sub
    
    Public Sub DownloadString(ByVal myConnection As OracleConnection)
    
      myConnection.Unicode = True
      Dim myCommand As New OracleCommand("SELECT * FROM Test.TextBlocks", myConnection)
      myConnection.Open()
      Dim myReader As OracleDataReader = myCommand.ExecuteReader(CommandBehavior.Default)
      Try
        While myReader.Read()
          Dim myString As String = CType(myReader("BlockContent"), String)
          Console.WriteLine(myString)
        End While
      Finally
        myReader.Close()
        myConnection.Close()
      End Try
    End Sub
    Requirements

    Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also