R
richard
i recently encount a strange problem.
first , i successfully insert a record to db, but when i try to update this record, i always get a
DBConcurrencyException exception.
but when i change "using System.Data.OracleClient" to "using Oracle.DataAccess.Client", everything is OK.
To make things worse, i have encount the same problem before when i update another table, at that time, i fixed it by
change "using Oracle.DataAccess.Client" to "using System.Data.OracleClient",
the code is as the follow:
using System.Data;
using System.Data.OracleClient;
//using Oracle.DataAccess.Client;
private void button1_Click(object sender, System.EventArgs e)
{
OracleConnection conn = null;
try
{
conn = new OracleConnection("User Id=news;Password=news;Data Source=NEWS");
conn.Open();
String sql ="select * from action_rule where action_rule_id = 10000126 and branch = 2";
OracleDataAdapter adapter = new OracleDataAdapter(sql, conn);
OracleCommandBuilder builder = new OracleCommandBuilder(adapter);
DataTable table = new DataTable();
adapter.Fill(table);
DataRow row = table.Rows[0];
row["expire_time"] = 70;
adapter.Update(table);
Console.WriteLine("OK");
}
catch(Exception ex)
{
Console.WriteLine(ex.ToString());
}
finally
{
conn.Close();
}
}
besides, the follow code can work
private void button1_Click(object sender, System.EventArgs e)
{
OracleConnection conn = null;
try
{
conn = new OracleConnection("User Id=news;Password=news;Data Source=NEWS");
conn.Open();
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
cmd.CommandText = "update action_rule set expire_time = 50 where action_rule_id = 10000066";
cmd.ExecuteNonQuery();
Console.WriteLine("OK");
}
catch(Exception ex)
{
Console.WriteLine(ex.ToString());
}
finally
{
conn.Close();
}
}
i have been tired at this problem for many days, anyone knows the reason? thanks advance.
first , i successfully insert a record to db, but when i try to update this record, i always get a
DBConcurrencyException exception.
but when i change "using System.Data.OracleClient" to "using Oracle.DataAccess.Client", everything is OK.
To make things worse, i have encount the same problem before when i update another table, at that time, i fixed it by
change "using Oracle.DataAccess.Client" to "using System.Data.OracleClient",
the code is as the follow:
using System.Data;
using System.Data.OracleClient;
//using Oracle.DataAccess.Client;
private void button1_Click(object sender, System.EventArgs e)
{
OracleConnection conn = null;
try
{
conn = new OracleConnection("User Id=news;Password=news;Data Source=NEWS");
conn.Open();
String sql ="select * from action_rule where action_rule_id = 10000126 and branch = 2";
OracleDataAdapter adapter = new OracleDataAdapter(sql, conn);
OracleCommandBuilder builder = new OracleCommandBuilder(adapter);
DataTable table = new DataTable();
adapter.Fill(table);
DataRow row = table.Rows[0];
row["expire_time"] = 70;
adapter.Update(table);
Console.WriteLine("OK");
}
catch(Exception ex)
{
Console.WriteLine(ex.ToString());
}
finally
{
conn.Close();
}
}
besides, the follow code can work
private void button1_Click(object sender, System.EventArgs e)
{
OracleConnection conn = null;
try
{
conn = new OracleConnection("User Id=news;Password=news;Data Source=NEWS");
conn.Open();
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
cmd.CommandText = "update action_rule set expire_time = 50 where action_rule_id = 10000066";
cmd.ExecuteNonQuery();
Console.WriteLine("OK");
}
catch(Exception ex)
{
Console.WriteLine(ex.ToString());
}
finally
{
conn.Close();
}
}
i have been tired at this problem for many days, anyone knows the reason? thanks advance.