public IList <Category> GetAllCategoryAdo() { //Create Procedure GetAllCategories //As //Begin //Select* from Category //end SqlConnection conn = pga.OpenConnection(); IList <Category> categoryList = new List <Category>(); SqlCommand command = new SqlCommand("GetAllCategories", conn); command.CommandType = System.Data.CommandType.StoredProcedure; using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { Category category = new Category(); category.CategoryId = Convert.ToInt32(reader["CategoryId"]); category.CategoryName = (reader["CategoryName"]).ToString(); categoryList.Add(category); } } pga.CloseConnection(conn); return(categoryList); }
public IList <Product> GetAllProductsAdo() { SqlConnection conn = pga.OpenConnection(); IList <Product> productList = new List <Product>(); SqlCommand command = new SqlCommand("spGetAllProducts", conn); command.CommandType = System.Data.CommandType.StoredProcedure; using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { Product product = new Product(); product.ProductId = Convert.ToInt32(reader["ProductId"]); product.ProductName = (reader["ProductName"]).ToString(); product.CategoryId = Convert.ToInt32(reader["CategoryId"]); product.ManufacturerId = Convert.ToInt32(reader["ManufacturerId"]); product.Description = (reader["Description"].ToString()); product.Stock = Convert.ToInt32(reader["Stock"]); product.Price = Convert.ToInt32(reader["Price"]); product.Display = (reader["Display"].ToString()); product.Processor = (reader["Processor"].ToString()); product.Memory = (reader["Memory"].ToString()); product.VideoMemory = (reader["VideoMemory"].ToString()); product.HDD = (reader["HDD"].ToString()); product.Camera = (reader["Camera"].ToString()); productList.Add(product); } } pga.CloseConnection(conn); return(productList); //Create Procedure spGetAllProducts //As //Begin //Select* from Product //End }