Example #1
0
        public static IList <TFabricante> GetTFabricantes(SqlCeConnection conn)
        {
            IList <TFabricante> lttpa = new List <TFabricante>();
            string sql = "SELECT * FROM Fabricante";

            using (SqlCeCommand cmd = conn.CreateCommand())
            {
                cmd.CommandText = sql;
                SqlCeDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    TFabricante ta = GetTFabricante(dr.GetInt32(0), conn);
                    lttpa.Add(ta);
                }
            }
            return(lttpa);
        }
Example #2
0
        public static TFabricante GetTFabricante(string nombre, SqlCeConnection conn)
        {
            TFabricante ta  = null;
            string      sql = String.Format("SELECT * FROM Fabricante WHERE nombre='{0}'", nombre);

            using (SqlCeCommand cmd = conn.CreateCommand())
            {
                cmd.CommandText = sql;
                SqlCeDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    ta = new TFabricante();
                    ta.FabricanteId = dr.GetInt32(0);
                    ta.Nombre       = dr.GetString(2);
                    ta.Abm          = dr.GetByte(3);
                }
                if (!dr.IsClosed)
                {
                    dr.Close();
                }
            }
            return(ta);
        }