cdiego

DAOCategoria

Jul 13th, 2013
405
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.08 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Data;
  6. using System.Data.SqlClient;
  7. using ENTIDADES;
  8. using System.Web;
  9. using System.Web.Configuration;
  10.  
  11. namespace DAO
  12. {
  13.     public class DAOCategoria
  14.     {
  15.         private string cadena;
  16.         public DAOCategoria()
  17.         {
  18.             cadena = WebConfigurationManager.ConnectionStrings["cadena"].ConnectionString;
  19.         }
  20.         public List<eCategoria> ListarTodo()
  21.         {
  22.             SqlConnection con = new SqlConnection(cadena);
  23.             SqlCommand cmd = new SqlCommand("SP_CATEGORIA_LISTAR_TODO", con);
  24.             List<eCategoria> lista = new List<eCategoria>();
  25.             con.Open();
  26.             SqlDataReader lector = cmd.ExecuteReader();
  27.             while (lector.Read())
  28.             {
  29.                 eCategoria p = new eCategoria();
  30.                 p.IdCategoria = lector.GetInt32(0);
  31.                 p.NombreCat = lector.GetString(1);
  32.                 lista.Add(p);
  33.             }
  34.             con.Close();
  35.             return lista;
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment