在过去的几个小时中,我尝试更新oracle表,但是OracleCommand始终返回0。任何帮助将不胜感激。
string strConnection = @"Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)
(HOST=localhost)(PORT=##))(CONNECT_DATA=(SERVICE_NAME=###)));" +
"User Id = ###; Password = ###;";
using (OracleConnection connection = new OracleConnection(strConnection))
{
char quote = '"';
string strCommand = @"update test set " + quote +"ID"+quote+"=:id," +
quote + "NAME" + quote + "=:name where " + quote + "AGE" + quote +
"=:age";
OracleCommand command = new OracleCommand(strCommand,connection);
command.Parameters.Add(new OracleParameter("id", "32"));
command.Parameters.Add( new OracleParameter("name", "Justin"));
command.Parameters.Add( new OracleParameter("age", "95"));
connection.Open();
int res = command.ExecuteNonQuery(); /// 0 always
Console.WriteLine("Result = " + res.ToString());
Console.ReadKey();
}