gpt4 book ai didi

MySQL ExecuteNonQuery() 不执行任何操作

转载 作者:行者123 更新时间:2023-11-30 00:06:07 26 4
gpt4 key购买 nike

我有最简单的代码...

// Connect to database etc
string sqlStr = "INSERT INTO .... ... ";
MySqlCom.CommandText = sqlStr;
int n = MySqlCom.ExecuteNonQuery();

我已经查看了这段代码 100 遍,只是无法弄清楚,就像我在错误的数据库中查找,但我不确定......我确信这一点。

n 甚至返回 1,但代码执行后数据并不在数据库中。它不会失败,不会提示任何事情,而且我可以将 sqlStr 复制到工作台中,它工作得很好。

有没有什么情况下MySQL会执行代码但不会实际将数据写入数据库,并且不会抛出错误?

最佳答案

Is there any circumstance that MySQL would execute the code but not actually write the data to the database, and not throw an error?

当您使用事务并且不发出提交时。

关于MySQL ExecuteNonQuery() 不执行任何操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24532553/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com