MySqlConnection connection = new MySqlConnectio(connectionString); using (MySqlCommand cmd = new MySqlCommand(safeSql, connection)) { try { connection.Open(); return cmd.ExecuteNonQuery(); } catch (Exception ex) { connection.Close(); return 0; } }