Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
|
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 7th, 2014, 09:28 AM
Registered User
 
Join Date: Jul 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default There is already an open DataReader associated with this Command which must be closed

I tried to add support for multi levels categories by adding ParentCategoryID to the Categories table and make necessary modification to stored procedures, DAL and BLL.
but now i get this error "There is already an open DataReader associated with this Command which must be closed" at ExecuteReader(DbCommand cmd, CommandBehavior behavior)

Category.cs
public static List<Category> GetCategories()
{
List<Category> categories = null;
string key = "Articles_Categories";

if (BaseArticle.Settings.EnableCaching && BizObject.Cache[key] != null)
{
categories = (List<Category>)BizObject.Cache[key];
}
else
{
List<CategoryDetails> recordset = SiteProvider.Articles.GetCategories();
categories = GetCategoryListFromCategoryDetailsList(recordset);
BaseArticle.CacheData(key, categories);
}
return categories;
}

SqlArticlesProvider.cs
public override List<CategoryDetails> GetCategories()
{
using (SqlConnection cn = new SqlConnection(this.ConnectionString))
{
SqlCommand cmd = new SqlCommand("WS_Articles_GetCategories", cn);
cmd.CommandType = CommandType.StoredProcedure;
cn.Open();
return GetCategoryCollectionFromReader(ExecuteReader(cmd) );
}
}

DataAccess.cs
protected IDataReader ExecuteReader(DbCommand cmd)
{
return ExecuteReader(cmd, CommandBehavior.Default);
}

protected IDataReader ExecuteReader(DbCommand cmd, CommandBehavior behavior)
{
return cmd.ExecuteReader(behavior);
}





Similar Threads
Thread Thread Starter Forum Replies Last Post
There is already an open datareader associated wit yasinirshad ADO.NET 1 August 12th, 2007 03:37 AM
There is already an open DataReader associated wit jayanp ADO.NET 1 July 2nd, 2006 01:10 PM
There is already an open DataReader associated wit flyin ADO.NET 14 February 20th, 2004 08:41 AM
"There is already an open DataReader " error kaz VS.NET 2002/2003 4 December 17th, 2003 11:43 PM
Access Database: Open or closed?? Sach Classic ASP Databases 1 October 17th, 2003 06:21 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.