puedes usar MySqlTransaction, aqui te dejo un ejemplo.
protected void btnSubmit_Click(object sender, EventArgs e)
{
// Defines la variable
MySqlTransaction tr = null;
try
{
// Abres la conexion
conn.Open();
// Inicializas la transaccion
tr = conn.BeginTransaction();
MySqlCommand cmd = new MySqlCommand();
cmd = new MySqlCommand("Insert into student (Name,Address,Mobile,Email ) values (@Name,@Address,@Mobile,@Email)", conn,tr);
cmd.Parameters.AddWithValue("@Name", txtName.Text);
cmd.Parameters.AddWithValue("@Address", txtAddress.Text);
cmd.Parameters.AddWithValue("@Mobile", txtMobile.Text);
cmd.Parameters.AddWithValue("@Email", txtEmail.Text);
cmd.ExecuteNonQuery();
cmd = new MySqlCommand("Insert into courses (Course,Name,Amount ) values (@Course,@Name1,@Amount )", conn,tr);
cmd.Parameters.AddWithValue("@Name1", txtName.Text);
cmd.Parameters.AddWithValue("@Course",ddlCourse.SelectedValue.ToString());
cmd.Parameters.AddWithValue("@Amount",txtAmount.Text);
cmd.ExecuteNonQuery();
tr.Commit();
cmd.Dispose();
ShowMessage("Student Course Enrollment Successfully......!");
clear();
BindStudentGridView(); BindCoursesGridView();
}
catch (MySqlException ex)
{
tr.Rollback();
ShowMessage(ex.Message);
}
finally
{
conn.Close();
}
}
Espero te sirva. Saludos.