title: Display the data from SQL database
body: <p>I have designed a Form in VS 2008. I have a database table containing the following fields:</p>
  
  <pre><code>Fname (char)
  MailFrom (char)
  MailTo (char)
  Subject (char)
  Body (char)
  MailID (int)
  </code></pre>
  
  <p>Now I to extract the data from the database and display it on the form in their respective fields.</p>
  
  <p>my code behind is:</p>
  
  <pre><code>SqlConnection conn = new SqlConnection(
          "Data Source=PTZ1\\SQLEXPRESS;Initial Catalog = test; Integrated Security=SSPI;User ID=sa; Password=sa@; Trusted_Connection=True;");
  
      SqlDataReader rdr = null;
  
      try
      {
          // Open the connection
          conn.Open();
  
          // Pass the connection to a command object
          SqlCommand cmd = new SqlCommand("select * from testing", conn);
  
          //
          // Use the connection
          //
  
          // get query results
          rdr = cmd.ExecuteReader();
  
          while (rdr.Read())
          {
              Console.WriteLine(rdr[]);
          }
      }
      finally
      {
          // close the reader
          if (rdr != null)
          {
              rdr.Close();
          }
  
          // Close the connection
          if (conn != null)
          {
              conn.Close();
          }
      }
  </code></pre>
  
  <p>How do I store and display the data on the console</p>