I'm using MySQL's AUTO_INCREMENT field and InnoDB to support transactions. I noticed when I rollback the transaction, the AUTO_INCREMENT field is not rollbacked? But when I don't call RollBack the id doesn't change.
try
{
//My Code
}
catch (MySqlException ex)
{
//deadlock exception in mysql
if (ex.Number == 1213)
{
//I don't use RollBack and the id dosen't change
MessageBox.Show("Try again", "Warning");
}
else
{
msqlTr.Rollback();
txtError.Text = "Erreur : " + ex.Message;
Log.LogError.setError(ex);
MessageBox.Show("Erreur : " + ex.Message, "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
catch (Exception ex)
{
msqlTr.Rollback();
txtError.Text = "Erreur : " + ex.Message;
Log.LogError.setError(ex);
MessageBox.Show("Erreur : " + ex.Message, "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
If this code correct, I mean that when I don't call rollback?