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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:36:36+00:00 2026-05-19T03:36:36+00:00

currently I use DataSet to read data from ADO.NET SQL provider, but I read

  • 0

currently I use DataSet to read data from ADO.NET SQL provider, but I read that DataReader is more efficient for some cases. Many a times I only read single/few records and don’t need in-memory data or multiple table relation manipulations.

  1. Are there more clean and efficient ways to read ?

  2. Can I in simple way map the full record directly to the Agent class, without having to parse out each column like I do now?

EDIT: – I have investigated somewhat on ORMs and used Linq2SQL a little, but the familiarity curve seems little steep, so left it at that. Please suggest other ways available within .NET and not any external tools.

public override Agent GetAgentByAgentId(string agentId)
{
   Agent agent;

   try
   {
      ArrayList paramList = new ArrayList();
      paramList.Add(_dbUtilities.CreateSqlParamater("@agent_id", SqlDbType.VarChar, 10, ParameterDirection.Input, agentId));

      // Query the database for an agent with given agentId
      DataSet ds = _dbLib.ExecuteProcedureDS("sp_dbc_agentsSelect", paramList);

      if (ds != null && ds.Tables != null && ds.Tables.Count > 0)
      {
         DataTable dt = ds.Tables[0];

         if (dt.Rows.Count > 0)
         {
            agent = new Agent();
            DataRow dr = dt.Rows[0];

            // Get the agent data
            agent.IsActive = bool.Parse(dr["is_active"].ToString());
            agent.UserId = dr["user_id"].ToString();
            ....
          }
        }
  • 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-19T03:36:37+00:00Added an answer on May 19, 2026 at 3:36 am

    First, I’d like to recommand SLak’s answer. This really is the answer to your question. I understand your trepidation about using large toolsets like EF, but it’s really the right solution and doesn’t have as much of a learning curve as you might think. There’s very little reason to go straight to things like a DataReader anymore. EF is part of .NET and I can’t encourage you enough to use it.

    Likewise, don’t go down the road of creating your own ORM of sorts with decorations and automatic code generation and the like. Do. Not. Do. It. In the end, you’ll spend as much time maintaining that as you do your business logic, and you’ll kick yourself for not using the work of many people who are a lot smarter than I am and probably you, as well 😉 (No offense, of course). If you’re looking for quick-and-dirty, then you need to go quick-and-dirty.

    That being said, using a DataReader is the most lightweight method for reading data from the database.

    I’m not sure exactly how to answer your first question, other than to give you an example of using a DataReader in C#.

    using(DbConnection conn = new SqlConnection("connection string"0)
    {
        conn.Open();
    
        using(DbCommand cmd = conn.CreateCommand())
        {
            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "sql statement";
    
            using(IDataReader reader = cmd.ExecuteReader())
            {
                while(reader.Read())
                {
                    var column1 = reader["column1"];
                }
            }
        }
    }
    

    The while statement will execute for every row retrieved from the reader, though you can certainly short-circuit that loop if need be and not parse the entire result set.

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

Sidebar

Related Questions

I currently have a function that gets some data from the database and puts
I am trying to use LinqDataSource instead of using the SQL dataset. Currently, if
I currently use the free obfuscation tool that ships with VS and it does
I need to read from a dataset which is very large, highly interlinked, the
Many data analysts that I respect use version control. For example: http://github.com/hadley/ See comments
I am trying to build a data processing program. Currently I use a double
I have a web application that has a requirement to take data from an
Currently I am storing the DataSet in a ViewState but, this may have an
Hello I am analyzing some data and trying to use a package that contains
I'm currently looking to use Microsoft Sync Framework (2.1) to sync clients (running SQL

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.