title: C# DataRow.ToString() automatically formats the string when it shouldn't
body: <p>I have been programming for a while, but I have never seen this happen so I'm kind of baffled as to what's happening. What I'm doing is I'm executing a SP on a database and just to test it's output before I actually use it I'm putting the rows into pipe delimited strings. For some reason when I set a textbox to these results it formats the dates from SQL Server into DateTime variables and 1.99 decimals into 1.9900 decimals.</p>
  
  <p>Also just a note: I don't want to access the column data by calling specific columns by column name. I want to make it so that I can change and add columns to the SP in the database and this would continue to work and bring back all columns from the SP.</p>
  
  <p>Also the seconds on the last datetime aren't the same because the queries were run at different times so no need to worry about that.</p>
  
  <p>Anyone have any idea what's going on here??</p>
  
  <p>Here is the code that gets the data and creates the pipe delimited strings:</p>
  
  <pre><code>private string GetHourlySales()
  {
      StringBuilder output = new StringBuilder();
      DataTable tblData = new DataTable();
  
      using (SqlConnection conn = new SqlConnection(GetConnectionString()))
      {
          string sql = "EXEC [dbo].[ryan_GetSalesSummary] 0";
          using (SqlCommand cmd = new SqlCommand(sql, conn))
          {
              try
              {
                  conn.Open();
                  SqlDataReader dr = cmd.ExecuteReader();
                  tblData.Load(dr, LoadOption.Upsert);
                  conn.Close();
              }
              catch (Exception) { }
          }
      }
  
      foreach (DataRow row in tblData.Rows)
      {
          for (int i = 0; i &lt; tblData.Columns.Count; i++)
          {
              if (i &gt; 0)
                  output.Append("|");
              if (i == tblData.Columns.Count - 1)
                  output.AppendLine(row[i].ToString());
              else
                  output.Append(row[i].ToString());
          }
      }
  
      if (tblData.Rows.Count &gt; 0)
          return output.ToString();
      else
          return null;
  }
  </code></pre>
  
  <p>Here is the output that it creates:
  <img src="https://i.stack.imgur.com/udlcW.png" alt="incorrect formatting"></p>
  
  <p>Here is what I get straight from SQL Server:
  <img src="https://i.stack.imgur.com/c267L.png" alt="correct formatting"></p>