title: how to convert the entire content of a DataTable column to a delimited string in C#?
body: <p>I am retrieving data from an MSSQL server using the SqlDataAdapter and DataSet.  From that DataSet I am creating a DataTable.  My goal is to convert each column of the table into a string where the elements are comma delimited.  I figured that I would try the string conversion first before making the delimiter work.</p>
  
  <p>The code runs in the code-behind of an ASP.Net page.  The ultimate goal is to pass the string to a jscript variable, it's a "functional requirement" that I create a delimited string from the columns and that it has to end up as a jscript variable.</p>
  
  <p>Here's what I have thus far:</p>
  
  <pre><code>    DataSet myDataSet = new DataSet();
      mySqlDataAdapter.Fill(myDataSet);
      DataTable temperature = myDataSet.Tables["Table"];
  
      // LOOP1
      foreach (DataRow row in temperature.Rows)
      // this loop works fine and outputs all elements
      // of the table to the web page, this is just to
      // test things out
      {
          foreach (DataColumn col in temperature.Columns)
          {
              Response.Write(row[col] + " ### ");
          }
          Response.Write("&lt;br&gt;");
      }
  
      // LOOP2
      foreach (DataColumn column in temperature.Columns)
      // this loop was meant to take all elements for each
      // column and create a string, then output that string
      {
          Response.Write(column.ToString() + "&lt;br&gt;");
      }
  </code></pre>
  
  <p>In LOOP1 things work fine.  My data has 4 columns, all are appropriately rendered with one record per row on the web page.</p>
  
  <p>I saw the code for LOOP2 at <a href="http://msdn.microsoft.com/en-us/library/system.data.datacolumn.tostring.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/system.data.datacolumn.tostring.aspx</a> which seems to do exactly what I need except it does not actually do what I want.</p>
  
  <p>The only thing LOOP2 does is write 4 lines to the web page.  Each line has the header of the respective table column but none of the additional data.  Clearly there's either a logic flaw on my part or I misunderstand how DataColumn and .toString for it works.  Please help me out on this one.  Thanks in advance.</p>
  
  <p>EDIT:
  Here's an SQL query result example, this is what the Table looks like:
  <a href="http://img811.imageshack.us/i/queryresult.png/" rel="noreferrer">Table quesry result @ ImageShack</a></p>
  
  <p>What I want to end up are four strings, here's an example for the string that would be created from the second column: "-6.7, -7, -7.2, -7.3, -7.3".</p>