title: Read table[columns] and display in console
body: <p>I have one table and about 20 columns which contain more than 5000 rows. 
  Right now I want to display all 20 columns in console, and I came to thirth column and I get error</p>
  
  <pre><code>System.FormatException: 'Index (zero based) must be greater than or equal to zero and less than the size of the argument list.'
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>using System;
  using System.Data.SqlClient;
  
  namespace DbToJSON
  {
      class Program
      {
          static void Main(string[] args)
          {
              string constring = @"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=Test;Integrated Security=True";
              string Query = "select * from AO_ASISTENCA";
  
  
              SqlConnection conDataBase = new SqlConnection(constring);
              SqlCommand cmd = new SqlCommand(Query, conDataBase);
              conDataBase.Open();
              using (SqlCommand command = new SqlCommand(Query, conDataBase))
              {
  
                  using (SqlDataReader reader = command.ExecuteReader())
                  {
                      while (reader.Read())
                      {
                         Console.WriteLine("{0}", reader.GetString(0));
                         Console.WriteLine("{0}", reader.GetString(1));
                         Console.WriteLine("{1}", reader.GetString(0));
  
  
                      }
                  }
              }
  
          }
  
      }
  }
  </code></pre>
  
  <p>This peace of code make me error </p>
  
  <pre><code>Console.WriteLine("{1}", reader.GetString(0));
  </code></pre>
  
  <p>When I change this to </p>
  
  <pre><code>Console.WriteLine("{0}", reader.GetString(2));
  </code></pre>
  
  <p>Anyone can guide me and tell me what's wrong with this. Maybe I am doing something wrong, but I  can not figure out what's wrong with this. 
  Thanks</p>