See Also

OracleConnection Class  | OracleConnection Members  | ConnectionString Property

Language

Visual Basic

C#

Show All

See AlsoLanguagesDevart.Data.OracleSend comments on this topic.

Unicode Property

Devart.Data.Oracle Namespace > OracleConnection Class : Unicode Property (OracleConnection)

Gets or sets a value indicating whether the UTF16 charset will be used.

[Visual Basic]
Public Property Unicode As Boolean
[C#]
public bool Unicode {get; set;}

Return Type

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.

[C#] 

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(); 
  } 

[Visual Basic] 

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

See Also

OracleConnection Class  | OracleConnection Members  | ConnectionString Property

 

 


© 2002 - 2013 Devart. All Rights Reserved.