Wrong interpretation of special characters ( Oracle provider )

  • Thread starter Thread starter Arjan Pottjewijd
  • Start date Start date
A

Arjan Pottjewijd

Dear Sirs,

I think we found a bug within the .NET Oracle Provider (
System.Data.OracleClient ). When we try to update or
insert a varchar text into any oracle field with
characters like: "ë, è, ô, Ñ, etc" the update fails. A
wrong character will be inserted.

Here is a code example:

System.Data.OracleClient.OracleConnection myConnection =
new System.Data.OracleClient.OracleConnection
("my connectionstring");

System.Data.OracleClient.OracleCommand myCommand =
myConnection.CreateCommand();

myCommand.CommandText =
"Update tablename set fieldname = " +
":myValue where id= :myID";

myCommand.Parameters.Add(":myValue",
System.Data.OracleClient.OracleType.VarChar,50);

myCommand.Parameters.Add(":myID",
System.Data.OracleClient.OracleType.Number);

myCommand.Parameters[":myValue"].Value = "My problëm.";
myCommand.Parameters[":myID"].Value = 10;
myCommand.ExecuteNonQuery();

The value "My problëm." will not be updated / inserted
correctly because of the ë character.

A work- around would be:

System.Data.OracleClient.OracleConnection myConnection =
new System.Data.OracleClient.OracleConnection(
"my connectionstring");

System.Data.OracleClient.OracleCommand myCommand =
myConnection.CreateCommand();

myCommand.CommandText = "Update tablename set fieldname
= 'My problëm' where id= 10";

myCommand.ExecuteNonQuery();

But if this is the only solution it would mean a lot of re-
programming for us to a worse situation.

I hope anyone has a better workaround or more information
about this issue.

Best regards,

Arjan Pottjewijd.
 
Back
Top