Example #1
0
        public List <TopicoModel> ObtenerTopicosArticulo(int id)
        {
            List <TopicoModel> topicos = new List <TopicoModel>();

            String connectionString = ConfigurationManager.ConnectionStrings["Grupo4Conn"].ConnectionString;
            String sqlString        = "SELECT Topico.nombreTopicoPK FROM Topico JOIN TopicosArticulo ON idArticuloFK = @id";

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                using (SqlCommand command = new SqlCommand(sqlString, connection))
                {
                    connection.Open();
                    command.Parameters.AddWithValue("@id", id);

                    SqlDataReader reader = command.ExecuteReader();

                    while (reader.Read())
                    {
                        TopicoModel topicoActual = new TopicoModel((string)reader["nombreTopicoPK"]);
                        topicos.Add(topicoActual);
                    }
                }
            }
            return(topicos);
        }
Example #2
0
        public List <TopicoModel> ObtenerAllTopicos()
        {
            List <TopicoModel> topicos = new List <TopicoModel>();

            String connectionString = ConfigurationManager.ConnectionStrings["Grupo4Conn"].ConnectionString;
            String sqlString        = "SELECT Topico.nombreTopicoPK FROM Topico";

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                using (SqlCommand command = new SqlCommand(sqlString, connection))
                {
                    connection.Open();
                    SqlDataReader reader = command.ExecuteReader();

                    while (reader.Read())
                    {
                        TopicoModel topicoActual = new TopicoModel((string)reader["nombreTopicoPK"]);
                        topicos.Add(topicoActual);
                    }
                }
            }
            return(topicos);
        }