After you commit the transaction, you have to start another one. This means you need to move the BeginTransaction
method call into the loop, like so.
while (someStuff)
{
MySqlTransaction trans;
try
{
trans = conn.BeginTransaction();
cmd.CommandText = getPersonUpdateString();
cmd.ExecuteNonQuery();
cmd.CommandText = getBookUpdateString();
cmd.ExecuteNonQuery();
trans.Commit();
}
catch (Exception ex)
{
writeError("", ex);
try
{
trans.Rollback();
}
catch (MySqlException)
{
writeError("", ex);
}
}
}