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 67981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:20:42+00:00 2026-05-10T19:20:42+00:00

I am cleaning up the DataReaders in an old .NET 1.1 project that I

  • 0

I am cleaning up the DataReaders in an old .NET 1.1 project that I inherited.

The previous developer coded the data-access-layer in such a way that most of the DAL methods returned SqlDataReaders (thus leaving it up to the caller to properly call the .Close() or .Dispose() methods).

I have come across a situation, though, where a caller is not catching the returned SqlDataReader (and therefore is not disposing of it properly). See the code below:

Data Access Method:

Public Shared Function UpdateData() As SqlDataReader    ...     drSQL = cmdSQL.ExecuteReader(CommandBehavior.CloseConnection)     Return drSQL  End Function 

Calling code:

... DataAccessLayer.UpdateData() ... 

As you can see, the calling method does not receive/catch the returned SqlDataReader. So what happens? Is that SqlDataReader still out there and open? Or does it automatically get garbage collected since nothing is addressing it?

I couldn’t think of a way to debug and test this. If anybody has any ideas or suggestions that would be great.

  • 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. 2026-05-10T19:20:43+00:00Added an answer on May 10, 2026 at 7:20 pm

    i believe that it will get closed but not until the garbage-collector gets ’round to it, which may not be for a very long time…

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

Sidebar

Related Questions

Is there an easier way of cleaning up a database that has a ton
when cleaning & building my project in NetBeans there's a warning that says unsafe
I'm working on cleaning up an old Rails 2.3.5 app that uses Dragonfly to
In the process of cleaning up the folder/file structure on a project I inherited,
Cleaning a handful of warnings on a C# project I have inherited, I found
I'm working on a project involving cleaning a list of data on college majors.
While cleaning some code today written by someone else, I changed the access modifier
I am working on cleaning up a mess that another programmer started. The created
I'm cleaning up CSS from a previous designer. The file is messy. One example
I understand the benefits of cleaning all data and quoting data, etc, but I'm

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.