C# dataset sql questions
<p>What I have going on is a list of ID's (nc.txt) and a list of columns (listbox1).</p>

<p>I am trying to export from SQL all data from the list of ID's that match the list of columns.  I'm sure i dont have the dataset right.  Any help aprpicated.</p>

<p>update:
string contents = File.ReadAllText(textBox3.Text);</p>

<pre><code>            string id = id = Regex.Match(contents, @"CoreDBCaseID=(?&lt;id&gt;\d+)").Groups["id"].Value;
            string server = server = Regex.Match(contents, @"Server=(?&lt;Server&gt;[^;]+)").Groups["Server"].Value;
            string security = security = Regex.Match(contents, "Security=(?&lt;Security&gt;[^;]+)").Groups["Security"].Value;
            string database = database = Regex.Match(contents, "Database=(?&lt;Database&gt;[^\r]+)").Groups["Database"].Value;

            string[] data = new string[] {
                    string.Format("Table={0}", id),
                    string.Format("Server={0}", server),
                    string.Format("Security={0}", security),
                    string.Format("Database={0}", database),
                };
                    string sqltable = ("dbo.SLTDS_C" + id + "_Stdtable");
                    string ids = File.ReadAllLines(@"C:\nc.txt").Aggregate((f, s) =&gt; f + "," + s);
                    String cols = String.Join(",", listBox1.Items.Cast&lt;String&gt;().ToArray());
                    string sql = "select " + cols + " from sqltable where ([id] in (" + ids + "))";
            {
                SqlConnection con = new SqlConnection("Data Source=" + server + ";Initial Catalog=" + database + ";Integrated Security=" + security);
                con.Open();
                SqlDataAdapter tabadapter = new SqlDataAdapter(sql, con);
                DataSet dataset = new DataSet("dataset");
                tabadapter.FillSchema(dataset, SchemaType.Source,cols);
                DataTable tbltarget;
                tbltarget = dataset.Tables[cols];
                string headers = dataset.Tables[0].Columns.Aggregate((f, s) =&gt; f.Name + "," + s.Name);
                string sqldata = dataset.Tables[0].Rows.Aggregate((f, s) =&gt; f.Value + "," + s.Value);
                string output_text = tbltarget.Columns.Cast&lt;DataColumn&gt;().Select(col =&gt; col.ColumnName).Aggregate((current, next) =&gt; current + "|" + next) + "\r\n"
                + tbltarget.Rows.Cast&lt;DataRow&gt;().Select(row =&gt; row.ItemArray.Aggregate((current, next) =&gt; current.ToString() + "|" + next.ToString())).Cast&lt;string&gt;().Aggregate((current, next) =&gt; current + "\r\n" + next);
                {
                    File.WriteAllText(@"C:\outputtest.txt", output_text);
                }
                con.Close();
            }
        }
    }
}
</code></pre>

<p>Error 1 'System.Data.DataColumnCollection' does not contain a definition for 'Aggregate' and no extension method 'Aggregate' accepting a first argument of type 'System.Data.DataColumnCollection' could be found (are you missing a using directive or an assembly reference?)<br>
Error 2 'System.Data.DataRowCollection' does not contain a definition for 'Aggregate' and no extension method 'Aggregate' accepting a first argument of type 'System.Data.DataRowCollection' could be found (are you missing a using directive or an assembly reference?)  </p>
