Solved

Concatenate <list<list>> columns

Posted on 2012-04-09
4
332 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 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

695 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