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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:12:42+00:00 2026-06-14T09:12:42+00:00

This is my aspx code when i want to fetch just one record. conn

  • 0

This is my aspx code when i want to fetch just one record.

            conn = new SqlConnection(cs);
            string sql = "SELECT * FROM [school_database].[arrest_school].[registration_allstudent] where RegistrationId='llts4da2'";
            SqlCommand cmd = new SqlCommand(sql, conn);
            conn.Open();
            reader = cmd.ExecuteReader();
            reader.Read();
            Model.Registration regis = new Model.Registration();
            regis.Address = reader["Address"].ToString();
            return regis;

Now i want to fetch all the records and return regis array. How to do it.
I know how to count the row in read and then how to fill it regis array.
Regis has 5 fields…Address, city, name, class, phoneno

  • 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-14T09:12:43+00:00Added an answer on June 14, 2026 at 9:12 am

    To read all the records, one way is this:

    using(IDataReader reader = cmd.ExecuteReader())
    {
        List<Registration> result  = new List<Registration>();
        while(reader.Read())
        {
            result.Add(new Registration{Address=reader["Address"].ToString()});
        }
        return result;
    }
    

    Another way is this:

    DataTable t = new DataTable();
    t.Load(cmd.ExecuteReader);
    var result  = from c in t.AsEnumerable()
                  select new Registration{Address=c.Field<string>("Address")};
    return result.ToList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i made iPad application, i want to fetch data from this url, http://ipad.idealake.com/stockquote.aspx?id=SBIN and
how can i write this code from aspx page in code behind? <a href=skype:MySkype?call><img
this code will not pass the query string to default3.aspx on Image Button ..
I want build a custom Google search. I tried this one My Code <div>
In the aspx code view , we can code like this: <asp:ListBox runat=server> <asp:ListItem
Inside my .aspx I have some JSON code that looks like this: function someFunctionName()
I have used code like this: http://msdn.microsoft.com/en-us/library/dw70f090.aspx to access database before when working in
Language: asp This is sample of my code: str = www.example.com/gotobuy.aspx?id=1234 key_word = .obuy.
I have this: <textarea name=content></textarea> and in javascript code in the same aspx file
I want to reference a table cell via it's string ID in my code

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.