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

  • Home
  • SEARCH
  • 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 8829331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:48:38+00:00 2026-06-14T07:48:38+00:00

I am trying to create a list as below and updating it with values

  • 0

I am trying to create a list as below and updating it with values from the datareader. I need help in writing the code to update this list from the data reader.

internal IList<FilingDto> LoadStatusDtofromReader(IDataReader reader)
        {
            IList<FilingDto> filingstatus = new List<FilingDto>();

            while (reader !=null && reader.Read())
             {
                var dto = new FilingDto();
                var Year = (Decimal)reader["Year"];
                dto = new FilingDto()
                {

                    Controllerid = (Guid)reader["Collectorid"],
                    Status = DBNull.Value.Equals(reader["Status"]) ? string.Empty : reader["Status"].ToString(),
                    Year = Convert.ToInt32(Year),
                    Level = DBNull.Value.Equals(reader["Level"]) ? string.Empty : reader["ServiceLevel"].ToString()
                };

                filingstatus.Add(dto);
            }

            return status;
        }

The code to read from the datareader is as below but i am stuck in between please help me complete this

DataTable FilingStatus = new DataTable("FilingStatus");
                SqlConnection sqlcon = new SqlConnection(ConfigurationManager.ConnectionStrings["Connectionstring"].ConnectionString);
                sqlcon.Open();
                SqlCommand cmd = new SqlCommand("select Collectorid, Status, Year, Level from dbo.abc", sqlcon);

                using (IDataReader dr =  
  • 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-06-14T07:48:39+00:00Added an answer on June 14, 2026 at 7:48 am

    You should invoke ExecuteReader on SqlCommand object

    SqlCommand cmd = new SqlCommand("select Collectorid, Status, Year, Level from dbo.abc", sqlcon);
                SqlDataReader reader = cmd.ExecuteReader();
                try
                {
                    while (reader.Read())
                    {
                        Console.WriteLine(String.Format("{0}, {1}",
                            reader[0], reader[1]));
                    }
                }
                finally
                {
                    // Always call Close when done reading.
                    reader.Close();
                }
    

    I suggest to use ORM like Entity framework instead ADO.NET

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

Sidebar

Related Questions

I am trying to create a list where I want users to enter data
I'm trying to create a list of tasks that I've read from some text
I am trying to create a list that adds a new row of data
I am trying to create a list box that displays a set of data
I'm trying to create an inventory list (tab-delimited text, for the output) from XML
I'm trying to create a generic list from a specific Type that is retrieved
So I'm trying to create a simple list of posts from a certain category
I'm trying to create a list of events for an agenda. To do this,
I'm trying to create a list as below in Java. Maybe I'm naive to
I'm trying to create an object called List. This object has a method add

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.