简体   繁体   中英

MySQL ExecuteNonQuery() does nothing

I have the most simple code...

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

I have looked over this code 100 times, and just cant figure it out, its like im looking in the wrong database but im not... im sure of it.

The n even returns with say 1, but the data just isnt in the database after the code executes. It doesn't fail, it doesn't complain about anything, and i can copy the sqlStr into the Workbench and it works perfectly.

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

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

When you use transactions and don't issue a commit.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM