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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:31:37+00:00 2026-06-18T07:31:37+00:00

This is a newbie question, I am trying to build a class in C#

  • 0

This is a newbie question, I am trying to build a class in C# that is going to set the UserOrgs property for a user (each user can have more than 1)

I have this thus far:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;

/// <summary>
/// Summary description for clsRepUser
/// </summary>
public class clsUser
{
    private string userid;
    private List<string> userorgs;

    public string UserID
    {
        get
        {
            return userid;
        }
        set
        {
            userid = value;
        }
    }

    public List<string> UserOrgs
    {
        get
        {
            return userorgs;
        }
        set
        {
            userorgs = value;
        }
    }

    clsConn cCon = new clsConn();
    String connStr = "";
    public clsUser()
    {

    }

    public DataSet GetUserOrg(string UserID)
    {
        DataSet ds = new DataSet();
        SqlConnection conn = new SqlConnection(cCon.getConn());

        SqlCommand cmd = new SqlCommand("sp_getUserOrgs", conn);

        // 2. set the command object so it knows
        // to execute a stored procedure
        cmd.CommandType = CommandType.StoredProcedure;

        // 3. add parameter to command, which
        // will be passed to the stored procedure
        cmd.Parameters.Add(
            new SqlParameter("@UserID", UserID));

        try 
        {
            // Open the connection and execute the Command
            conn.Open();
            SqlDataAdapter sqlDA = new SqlDataAdapter();

            sqlDA.SelectCommand = cmd;
            sqlDA.Fill(ds);
        } 
        catch (Exception ex) 
        {
        } 
        finally 
        {
            conn.Close();
        }

        return ds;    
    }
}

How do I now populate the UserOrgs property of that user from the GetUserOrg function? Or am I way off on this?

  • 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-18T07:31:38+00:00Added an answer on June 18, 2026 at 7:31 am

    You are using a stored procedure so it’s hard to give you an exact code, but the idea is to go through all rows of your DataSet, and add the element of that row to your list using .Add() method. Something like this:

    foreach (DataRow dr in ds.Tables[0].Rows) {  
      userorgs.Add(dr["orgs_column"].ToString()); 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This seems like a newbie question except that I've been trying to wrap my
Afraid this is a newbie question. I'm trying to have social login links on
I apologize if this is a newbie question. I have been working on trying
I think that this is a newbie type question but I have quite understood
apology for this newbie question. I have created an html page (dash.html) that uses
Sorry for this newbie question, but I can't find on google what I need
I know that this is a newbie question but I am a newbie so
This is a Fluent NHibernate newbie question, so bear with me. I have a
This must be a very stupid newbie question, but I have spent my whole
This is obviously newbie question so please bear with me. While trying to compile

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.