Wrox Programmer Forums

Need to download code?

View our list of code downloads.

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
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old November 7th, 2014, 08:28 AM
Registered User
Points: 10, Level: 1
Points: 10, Level: 1 Points: 10, Level: 1 Points: 10, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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);
}
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 07:41 AM
"There is already an open DataReader " error kaz VS.NET 2002/2003 4 December 17th, 2003 10:43 PM
Access Database: Open or closed?? Sach Classic ASP Databases 1 October 17th, 2003 06:21 AM



All times are GMT -4. The time now is 02:41 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.