• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 339
  • Last Modified:

Concatenate <list<list>> columns

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
boukaka
Asked:
boukaka
  • 2
1 Solution
 
ambienceCommented:
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
 
boukakaAuthor Commented:
Oh shoot, I didn't mean to put it under Access, should have been under Programming Languages/C# and SQL Server
0
 
boukakaAuthor Commented:
This works PERFECTLY and so simple! Thank you, that's exactly what I needed.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now