Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3974168
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:32:11+00:00 2026-05-20T04:32:11+00:00

In my multi-layer application, a data access layer reads the database and returns SqlDataReader

  • 0

In my multi-layer application, a data access layer reads the database and returns SqlDataReader for collections of objects and SqlDataRecord for a single object to a business layer. A business layer has constructors that initialize either a SqlDataReader or SqlDataRecord. That seemed a natural design to follow, however I run into multiple problems with readers going out of scope and multiple concurrent readers. What is a better way to tackle this design ? Is it better to make a data layer return a dictionary of fields and dispose readers immediately? And is it better to use DataSets in place where streaming of data is not required?

Some examples of exceptions that I encounter in my application:
– Invalid attempt to call MetaData when reader is closed
– There is already an open DataReader associated with this Command which must be closed first

EDIT: found an excellent article Contrasting the ADO.NET DataReader and DataSet. Going to use DataSets whenever appropriate (disconnected, buffered approach).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T04:32:12+00:00Added an answer on May 20, 2026 at 4:32 am

    You definitely want to close the SqlDataReader connections as soon as possible. The SqlDataReader is very fast but when they remain open you are using up one of you connection pool connections. This could easily put you in a condition where you have resource issues, as you mentioned.

    I would not, as you suggested, pass a SqlDataReader to the business tier. I would either fill up a DataSet and pass that or construct a custom data entity object and return that to the business tier.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a layered application in Java which has a multi thread data access
We have a typical multi-tier/layer architecture. Application + WCF Service + Repository/EF4/Database. We are
I'm currently developing a small business database application for which we plan to go
When training a multi-layer neural network, using a sigmoidal activation function is necessary for
I have a multi-threaded application that is using pthreads. I have a mutex() lock
I am still learning .NET framework and I want to implement multi-tier application just
I'm creating a multi-tenant ASP.NET application using NHibernate (shared schema). I had intended to
I started to think about tracking changes in complex object graph in disconnected application.
In a multi-tenant ASP.NET MVC application based on Rob Conery's MVC Storefront, should I
I'm currently working on a multi-tenant application that employs Shared DB/Shared Schema approach. IOW,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.