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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:09:26+00:00 2026-05-11T02:09:26+00:00

Previously I’ve asked about inserting a column into a dataset . I now have

  • 0

Previously I’ve asked about inserting a column into a dataset. I now have a similar question…namely merging two or more columns into a single column.

Lets say I have the following data set:

DataSet ds = new DataSet(); ds.Tables.Add(new DataTable()); ds.Tables[0].Columns.Add('id', typeof(int)); ds.Tables[0].Columns.Add('firstname', typeof(string)); ds.Tables[0].Columns.Add('lastname', typeof(string)); 

I am needing to combine the ‘firstname’ and ‘lastname’ columns into a single column called ‘name’.

Would it be best for me to create a method that merges two columns together or a more general one that can be used to merge multiple columns together?

My idea is to create a generalized method sort of like the following:

MergeColumns(string format, string mergedColumn, DataTable dt, params string[] columnsToMerge)

The user supplies a format as follows: ‘{0} {1}’

mergedColumn is the name of the new column…but it must be able to be the same as one of the columns that will be merged cause in my real world case I’m merging ‘name’ and ‘given_names’ into ‘name’…but I still want to be able to use it if I ever needed to merge ‘street’, ‘city’, ‘state’ ‘postcode’ etc into a column called ‘address’.

The way I am thinking this would be used is as follows:

MergeColumns(‘{0} {1}’, ‘name’, dataTable, ‘firstname’, ‘lastname’);

given the above dataset, I would expect the resultant data set to look as follows:

DataSet ds = new DataSet(); ds.Tables.Add(new DataTable()); ds.Tables[0].Columns.Add('id', typeof(int)); ds.Tables[0].Columns.Add('name', typeof(string)); 

Does this seem like a reasonable approach? Does a method like this already exist? I don’t want to reinvent the wheel. Also, am I creating a method that does more than I actually need right now?

  • 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. 2026-05-11T02:09:27+00:00Added an answer on May 11, 2026 at 2:09 am

    it seems to me that this should happen in the data layer and not the logic layer. presumably the dataset consumer knows what data it needs and could request it from the datastore explicitly, without having to manipulate datasets.

    in a database scenario, i’m essentially proponing a multiple stored procedure approach and the dataset consumer would retrieve the data from the appropriate one.

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

Sidebar

Ask A Question

Stats

  • Questions 64k
  • Answers 64k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer You can pass the instance of MyClient class as the… May 11, 2026 at 10:53 am
  • added an answer Downloading an URL as a string is easy using System.Net.WebClient.DownloadString.… May 11, 2026 at 10:53 am
  • added an answer These are my notes from Reflectoring the source at some… May 11, 2026 at 10:53 am

Related Questions

Previously I have asked to strip text from a field and convert it to
Previously I've asked about inserting a column into a dataset . I now have
When I asked this previously I should have mentioned that it's particularly a light-weight
I previously asked how to do this in Groovy. However, now I'm rewriting my
I previously asked about what Mixins were, and have begun to get the gist
I previously asked a question regarding MX records (and appreciate the thoughtful answers I
I just installed SQL Server 2008 Express on my Vista SP1 machine. I previously
I was previously taught today how to set parameters in a SQL query in
I've previously used jquery-ui tabs extension to load page fragments via ajax , and
I've previously encountered the suggestion to call System.Threading.Thread.Sleep(0); in tights loops in C# to

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.