Solved

Concatenate <list<list>> columns

Posted on 2012-04-09
4
327 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
  • 2
4 Comments
 
LVL 22

Accepted Solution

by:
ambience earned 500 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now