public static TInstalacion GetTInstalacion(int id, SqlCeConnection conn) { TInstalacion instalacion = null; using (SqlCeCommand cmd = conn.CreateCommand()) { cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = String.Format("SELECT * FROM Instalacion WHERE instalacion_id = {0}", id); using (SqlCeDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { instalacion = new TInstalacion(); instalacion.InstalacionId = id; instalacion.Nombre = dr.GetString(1); instalacion.Abm = dr.GetByte(2); } if (!dr.IsClosed) { dr.Close(); } } } return(instalacion); }
public static void TSave(TInstalacion tr, SqlCeConnection conn) { string sql = ""; sql = @"INSERT INTO Instalacion(instalacion_id, nombre) VALUES({0},'{1}')"; sql = String.Format(sql, tr.InstalacionId, tr.Nombre); using (SqlCeCommand cmd = conn.CreateCommand()) { cmd.CommandText = sql; cmd.ExecuteNonQuery(); } }
public static IList <TInstalacion> GetTInstalaciones(SqlCeConnection conn) { IList <TInstalacion> lttpa = new List <TInstalacion>(); string sql = "SELECT * FROM Instalacion"; using (SqlCeCommand cmd = conn.CreateCommand()) { cmd.CommandText = sql; SqlCeDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { TInstalacion ta = GetTInstalacion(dr.GetInt32(0), conn); lttpa.Add(ta); } } return(lttpa); }
public static TInstalacion GetTInstalacion(string nombre, SqlCeConnection conn) { TInstalacion ta = null; string sql = String.Format("SELECT * FROM Instalacion WHERE nombre='{0}'", nombre); using (SqlCeCommand cmd = conn.CreateCommand()) { cmd.CommandText = sql; SqlCeDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { ta = new TInstalacion(); ta.InstalacionId = dr.GetInt32(0); ta.Nombre = dr.GetString(1); ta.Abm = dr.GetByte(2); } if (!dr.IsClosed) { dr.Close(); } } return(ta); }