I'm using your DLL to use a databaseMySQL in my C# project
What DLL are you using and where did it come from? If you found attached to an article that has been posted here it is best to contact the author of the article by using the
Comments / Discussions
widget at the bottom of the article.
That said, looking at your code I do not see anything that is not part of Oracle's MySql connector, so the documentation there is going to be pretty much a good outline to follow.
MySqlTransaction Class[
^]
For your code, I do not see anything wrong with the code as it is; are you 100% sure that your data is different before and after?
If the
nomAdresse address was already
forbl or there is no
idAdresse=8 present you would not see a change running this script.
I would suggest that for testing you expand out your query and better qualify or WHERE clause. Notice in the following block that I added an AND to the query itself as well as assigning a value to the NonQuery method. If RowsAffected equals 0 then there is nothing to roll back
using (MySqlConnection db = new MySqlConnection(connectionString)) {
MySqlTransaction transaction;
db.Open();
transaction = db.BeginTransaction();
string qry = "UPDATE t_adresse SET `nomAdresse`='forbl' WHERE idAdresse=8 AND `nomAdresse` <> 'forbl';";
MySqlCommand cmd = new MySqlCommand(qry, db, transaction);
int RowsAffected = cmd.ExecuteNonQuery();
transaction.Rollback();}