예제 #1
0
 public static IList<Familia> GetFamilias(string parNom)
 {
     IList<Familia> lf = new List<Familia>();
     using (MySqlConnection conn = GetConnection())
     {
         conn.Open();
         MySqlCommand cmd = conn.CreateCommand();
         string sql = @"SELECT
             f.codfamia AS CODFAMIA,
             f.nomfamia AS NOMFAMIA
             FROM sfamia AS f
             WHERE nomfamia LIKE '%{0}%'
             ORDER BY nomfamia";
         sql = String.Format(sql, parNom);
         cmd.CommandText = sql;
         MySqlDataReader rdr = cmd.ExecuteReader();
         if (rdr.HasRows)
         {
             while (rdr.Read())
             {
                 Familia f = new Familia();
                 f = GetFamilia(rdr);
                 if (f != null)
                     lf.Add(f);
             }
         }
         conn.Close();
     }
     return lf;
 }
예제 #2
0
 public static Familia GetFamilia(MySqlDataReader rdr)
 {
     if (rdr.IsDBNull(rdr.GetOrdinal("CODFAMIA")))
         return null;
     Familia f = new Familia();
     f.CodFamia = rdr.GetInt32("CODFAMIA");
     if (!rdr.IsDBNull(rdr.GetOrdinal("NOMFAMIA")))
         f.NomFamia = rdr.GetString("NOMFAMIA");
     return f;
 }