Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Invalid attempt to call FieldCount when reader is closed.

Posted on 2012-08-16
Medium Priority
Last Modified: 2012-08-21

Im populating a gridwiew with an object. The object is a shopping cart with cartitem objects in it.

grdwCart.DataSource = Cart.CartItems;

Open in new window

I have done this other places in the site, and it has worked.

Now i have copied the same code to another place and i get this message: Invalid attempt to call FieldCount when reader is closed. I guess it has to be something that i missed when copying. It would just help alot if i understood the error message.

I don,t know what that means?
Question by:Haugenwebdesign
  • 2
LVL 45

Assisted Solution

AndyAinscow earned 750 total points
ID: 38299505
At a guess you haven't opened the datasource - ie.  You haven't copied all of the relevant code.
LVL 20

Expert Comment

ID: 38300032
What is Cart.CartItems?

Is it the datareader?

Accepted Solution

Haugenwebdesign earned 0 total points
ID: 38300147
I made one small mistake.

I had:

grdwShoppingCart.DataSource = shoppingCart.CartItem;

Open in new window

I did this to make it work

grdwShoppingCart.DataSource = shoppingCart.CartItem;

Open in new window


Thanks for the help.

Author Closing Comment

ID: 38315439
Because this was the solution I ended up using, and it worked for me.

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
Integration Management Part 2
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month10 days, 10 hours left to enroll

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question