Py学习  »  DATABASE

mysql-C#在事务中抛出用户不退出例外

kuma DK • 3 年前 • 1308 次点击  

我正在C#中运行一个MySQL事务,但第二次查询失败。我可以通过以下方式获得豁免:

int no = sql_loc.ExecuteNonQuery();

db_local = "SERVER=localhost; Database=sync_r; UID=kandy; Password=kandy500;allow user variables=true";

MySqlConnection con_local = new MySqlConnection(db_local);
con_local.Open();

delq = "delete from tbl_recipes";  // all records
query = "insert into tbl_recipes(cat_id) values(6)";

MySqlTransaction tran = con_local.BeginTransaction();
MySqlCommand sql_loc = con_local.CreateCommand();
sql_loc.Transaction = tran;

sql_loc.CommandText = delq;
sql_loc.ExecuteNonQuery();
sql_loc.CommandText = query;
int no = sql_loc.ExecuteNonQuery();
if (no == 1)
    sql_loc.Transaction.Commit();
else
    sql_loc.Transaction.Rollback();

下面是抛出的错误

{"The user specified as a definer ('root'@'%') does not exist"}

但这不是我指定的用户。我该怎么解决这个问题??真正的问题在哪里?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/133223
 
1308 次点击  
文章 [ 1 ]  |  最新文章 3 年前