?
Solved

Concatenate <list<list>> columns

Posted on 2012-04-09
4
Medium Priority
?
335 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

777 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