Exemple #1
0
 public static int ExecuteNonReader(this SqlResult query)
 {
     using (var conn = new MySqlConnection(dbc))
     {
         try
         {
             conn.Open();
         }
         catch (Exception)
         {
             throw new Exception("Cannot connect to DB server");
         }
         using (var cmd = conn.CreateCommand())
         {
             cmd.CommandText = query.ConvertToSqlServer();
             cmd.Parameters.MapParameter(query.NamedBindings);
             var reader = cmd.ExecuteNonQuery();
             conn.Close();
             return(Convert.ToInt32(reader));
         }
     }
 }