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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:28:35+00:00 2026-05-26T17:28:35+00:00

I have created a method that can be called using a stored procedure name

  • 0

I have created a method that can be called using a stored procedure name and list of SqlParameters, lets call it GetData(). GetData() then manages talking to the SQL Server and getting the data. What I then need to do is hand the data back to the caller for them to read, they have no need to manipulate it. What I am trying to figure out is if it is best to hand the caller back a DataTable or SqlDataReader?

Right now, I am thinking that going with a DataTable is the best route. My decision points on this are:

  • The sets of data I am getting back are small, under 100 rows and 20 columns, so memory shouldn’t be an issue.
  • From what I understand, a DataTable grabs all of the data and plugs it into the DataTable, then disconnects itself so GetData() would manage it’s own connection.
  • With a SqlDataReader, I would have to manage the connection in the calling function after I am done with the data. I would not be able to close it after I have made the call in GetData() since I am only reading one row at a time from the database.

Does this seem like the best route to go for what I need?

  • 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-26T17:28:35+00:00Added an answer on May 26, 2026 at 5:28 pm

    Yes, your idea is good.

    Pass a datatable back, not the sqldatareader. Connections should only be maintained for the minimum amount of time necessary to transfer data to/from the database server.

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

Sidebar

Related Questions

I'm using entity framework 4. I have a stored procedure that just updates one
I have created a new method in one of the project's controllers that it
I have created a console application that calls a method on a webservice. I
Currently I have created a ABCFactory class that has a single method creating ABC
I have a recusive-method that creates a unordered list from a XML document. To
I have Created a Procedure for one of our .Net Devs where they can
I am using the core Auth component. I have created a user login that
Hey guys. I have a method that gets called each second which I want
I have a method that creates a MessageDigest (a hash) from a file, and
I have a method that creates a local textfield and pops up the keyboard

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.