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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:04:53+00:00 2026-06-13T12:04:53+00:00

Each user on my website has a reg_id . There are some emergency_contact_id ‘s

  • 0

Each user on my website has a reg_id. There are some emergency_contact_id‘s associated with this reg_id.

For example:

EmerContact_id  Reg_id    
  91              1    
  92              1    
  93              1    
  94              1    
  95              1

Now I want to store these EmerContact_id‘s into session like this:

Session["Emer1"]    
Session["Emer2"]    
Session["Emer3"]    
Session["Emer4"]    
Session["Emer5"]

How can I achieve this?

I am thinking of using:

while(reader.read()) { ... }

But I don’t know how to use it.

  • 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-13T12:04:54+00:00Added an answer on June 13, 2026 at 12:04 pm

    You can use MySqlDataReader and iterate through your results using an index marker, like this.

    using (MySqlConnection dbConnection = new MySqlConnection("connectionstring"))
    {
        dbConnection.Open();
    
        using (MySqlCommand dbCommand = new MySqlCommand("select EmerContact_id from [Table] order by EmerContact_id asc;", dbConnection))
        {
            using (MySqlDataReader dbReader = dbCommand.ExecuteReader())
            {
                int index = 1;
    
                while (dbReader.Read())
                {
                    Session["Emer" + index.ToString()] = dbReader[0].ToString();
    
                    index++;
                }
            }
        }
    
        dbConnection.Close();
    }
    

    You could also use a collection object like List and serialize this into the session.

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

Sidebar

Related Questions

My schema is quite simple- Each user has an id and name. There are
Say there is a website with 100,000 users each has up to 1000 unique
Here's the situation. Multi-million user website. Each user's page has a message section. Anyone
I'm re-writing a website from the ground up for azure. Each user has ownership
If I have a website where users login and logout, and each user has
I'm building website where each user has different classes +----+-----------+---------+ | id | subject
I want to create a website that has each of its pages stored on
Each user object in my database has an incremental ID (1, 2, 3, ...).
Each user of my site has their own profile page, which contains several items
For each user, I want to allow them to choose their preferences, such as

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.