Is not a hand mistake, this problem has bothered me so many days, is to update the code, using replace, but Oracle in. NET is not supported kanji, so-called using similar update x set y= ' m ' where y= ' kanji ' is not feasible. Parameters must be used.
Now the demand is to the database of Chinese characters "Spring", the overall change to "01", to the following to write:
oracleparameter[] Parameters = {New OracleParameter (": Spring", Oracle.DataAccess.Client.OracleDbType.NVarchar2)};
Parameters[0]. Value = "Spring";
String dbtable= "table name";
String setstr= "Termcode=replace (termname,:spring, ' 01 ')";//Note: Spring cannot be enclosed in single quotes, otherwise the error
String sql = string. Format ("Update {0} set {1}", DBTable, SETSTR);
using (oracleconnection connection = new OracleConnection (connectionString))
{
using (OracleCommand command = new OracleCommand (SQL, connection))
{
Command.commandtype = CommandType;
if (Parameters! = null)
{
foreach (oracleparameter parameter in parameters)
{
Command. Parameters.Add (parameter);
}
}
Connection. Open ();
Count = command. ExecuteNonQuery ();
}
}
C # uses OracleParameter while using the Replace function