I want to update some columns on my table but ExecuteNonQuery
doesn't respond (Timeout). Did I do something wrong?
Notes: in the database table, id
is integer, F1
varchar2 and the parameters I am sending are string and int.
try {
using (OracleConnection con = new OracleConnection(ConString)) {
con.Open();
OracleCommand cmd = new OracleCommand();
cmd.Connection = con;
cmd.CommandText = "UPDATE DB.Table "+
"SET F1= :yd" +
"WHERE ID = :id";
cmd.CommandType = CommandType.Text;
cmd.Parameters.Add("yd", yd);
cmd.Parameters.Add("id", id);
cmd.ExecuteNonQuery();
con.Close();
return true;
}
}
catch (Exception ex) {
return false;
}
Thanks
可以通过在Oracle开发人员或计算机上运行的任何其他IDE上 提交或回滚未决事务来解决此问题。
You're mixing up your parameter names. There is no parameter named "F1" in your query, use "yd".
cmd.CommandText = "UPDATE DB.Table "+
"SET F1= :yd" +
"WHERE ID = :id";
cmd.CommandType = CommandType.Text;
cmd.Parameters.Add("yd", yd);
cmd.Parameters.Add("id", id);
I found that is because of other program like toad locks the query. After commiting all thing in toad, everything is solved.
Thanks for all for helping. I love you guys, i like brainstorming :)
cmd.Connection = con;
string qry = "UPDATE DB.Table "+"SET F1= @yd" +"WHERE ID = @id";
OracleCommand cmd = new OracleCommand(qry,con);
cmd.Parameters.AddWithValue("@yd", yd);
cmd.Parameters.AddWithValue("@id", id);
cmd.ExecuteNonQuery();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.