title: Converting SqlDataReader column values to json string in C#
body: <p>I'd like to output a string (or possibly other variable type if string isn't ideal) based on the output of a SQLDataReader read. I have been playing around with the "while" loop,  <code>while (reader.Read())</code></p>
  
  <p>I need to end up with something I can serialize with json.net. </p>
  
  <p>Here's my current code - it outputs to debug log just to make sure I was successfully reading from the database. </p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
      {
  
          string connectionString = "Data Source =.\\SQLEXPRESS; Initial Catalog = TeamProject; Integrated Security = True; MultipleActiveResultSets = True";
  
          string querystring = "RosterMake";
  
          using (SqlConnection connection = 
              new SqlConnection(connectionString))
          {
              SqlCommand command = new SqlCommand(querystring, connection);
              command.CommandType = CommandType.StoredProcedure;
  
              try
              {
                  connection.Open();
                  SqlDataReader reader = command.ExecuteReader();
  
                  while (reader.Read())
                  {
                      System.Diagnostics.Debug.WriteLine("\t{0}\t{1}\t{2}",
                      reader[0], reader[1], reader[2]);
  
                      //  What do I put here to make the results something I can 
                      //  serialize with json.net???
  
                  }
                  reader.Close();
              }
              catch (Exception ex)
              {
                  System.Diagnostics.Debug.WriteLine("oops");
              }
          }
      }
  }
  </code></pre>
  
  <p>Thanks in advance!</p>