Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Concatenate <list<list>> columns

Posted on 2012-04-09
4
Medium Priority
?
338 Views
Last Modified: 2012-04-10
Hi,
I have a result set that is being returned from a stored procedure. This set is then populating a data table. I would like to combine 2 of the columns from the result set into one column in the data table but I can't figure out how to do it. I'd like to combine the GameType and the Teams  columns into one column named Teams, can anyone help?

The code is like this
<code>
 private void getUngradeList()
        {
            List<List<string>> storedProcedureResult = new List<List<string>>();
            List<string> parameters = new List<string>();

            parameters.Add(this.mdiParent.MyDate);
            parameters.Add(this.mdiParent.MyType);

            storedProcedureResult = Program.dataAccessManager.executeStoredProcedure(Constant.SP_NAME_GET_LIST_FOR_UNGRADE, parameters);
}
public DataTable buildUngradeDataSource(List<List<string>> _data)
        {

            DataTable dt = new DataTable("dataTable");
 //add columns and rows for Props
            if (this.mdiParent.MyType == "Props")
            {
               
                dt.Columns.Add("GameID", typeof(int));
                //dt.Columns.Add("Teams", typeof(string));
                dt.Columns.Add("Teams", typeof(string));
                dt.Columns.Add("GameDate", typeof(string));

                DataRow dataRow = dt.NewRow();

                string[] row2;

                _data.ForEach(delegate(List<string> row)
                {
                    int i = 0;
                    row2 = new string[row.Count];
                    dataRow["GameID"] = row[i++];
                    //dataRow["GameType"] = row[i++];
                    dataRow["Teams"] = row[i++];
                    dataRow["GameDate"] = row[i++];

                    dt.Rows.Add(dataRow);
                    dataRow = dt.NewRow();

                });

            }
</code>
0
Comment
Question by:boukaka
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 22

Accepted Solution

by:
ambience earned 2000 total points
ID: 37827342
Not sure what you mean by combining columns - can you paste contents of resultset?

At what index is the column for GameType?

Suppose there are two constants that define the index for teams and gametype columns in the row of the resultset then you can do this

dataRow["Teams"] = row[ kColumnIndexForTreams ] + row[ kColumnIndexForGameType ];

Would that help?
0
 

Author Comment

by:boukaka
ID: 37827377
Oh shoot, I didn't mean to put it under Access, should have been under Programming Languages/C# and SQL Server
0
 

Author Closing Comment

by:boukaka
ID: 37827411
This works PERFECTLY and so simple! Thank you, that's exactly what I needed.
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question