Unicode Property (OracleConnection)
On this page
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 oracleConnection)
{
oracleConnection.Unicode = true;
OracleCommand oracleCommand = new OracleCommand("INSERT INTO Test.TextBlocks (BlockID, BlockName, BlockContent) VALUES(1,'First',:BlockText)", oracleConnection);
oracleCommand.Parameters.Add("BlockText",OracleDbType.VarChar,50).Value = "Place here some text that requires Unicode support.";
oracleConnection.Open();
try
{
Console.WriteLine(oracleCommand.ExecuteNonQuery()+" rows affected.");
}
finally
{
oracleConnection.Close();
}
}
public void DownloadString(OracleConnection oracleConnection)
{
oracleConnection.Unicode = true;
OracleCommand oracleCommand = new OracleCommand("SELECT * FROM Test.TextBlocks", oracleConnection);
oracleConnection.Open();
OracleDataReader oracleReader = oracleCommand.ExecuteReader(CommandBehavior.Default);
try
{
while (oracleReader.Read())
{
string myString = (string)oracleReader["BlockContent"];
Console.WriteLine(myString);
}
}
finally
{
oracleReader.Close();
oracleConnection.Close();
}
} |
|
|---|
Public Sub UploadString(ByVal oracleConnection As OracleConnection)
oracleConnection.Unicode = True
Dim oracleCommand As New OracleCommand("INSERT INTO Test.TextBlocks (BlockID, BlockName, BlockContent) VALUES(1,'First',:BlockText)", oracleConnection)
oracleCommand.Parameters.Add("BlockText", OracleDbType.VarChar, 50).Value = "Place here some text that requires Unicode support."
oracleConnection.Open()
Try
Console.WriteLine(String.Concat(oracleCommand.ExecuteNonQuery(), " rows affected."))
Finally
oracleConnection.Close()
End Try
End Sub
Public Sub DownloadString(ByVal oracleConnection As OracleConnection)
oracleConnection.Unicode = True
Dim oracleCommand As New OracleCommand("SELECT * FROM Test.TextBlocks", oracleConnection)
oracleConnection.Open()
Dim oracleReader As OracleDataReader = oracleCommand.ExecuteReader(CommandBehavior.Default)
Try
While oracleReader.Read()
Dim myString As String = CType(oracleReader("BlockContent"), String)
Console.WriteLine(myString)
End While
Finally
oracleReader.Close()
oracleConnection.Close()
End Try
End Sub |
See Also