title: Select query to get data from SQL Server
body: <p>I am trying to run the SQL Select query in my C# code. But I always get the -1 output on </p>
  
  <pre><code>int result = command.ExecuteNonQuery();
  </code></pre>
  
  <p>However, the same table if I use for <code>delete</code> or <code>insert</code> works... </p>
  
  <p><code>ConnectString</code> is also fine.</p>
  
  <p>Please check below code</p>
  
  <pre><code>SqlConnection conn = new SqlConnection("Data Source=;Initial Catalog=;Persist Security Info=True;User ID=;Password=");
  conn.Open();
  
  SqlCommand command = new SqlCommand("Select id from [table1] where name=@zip", conn);
  
  //command.Parameters.AddWithValue("@zip","india");
  int result = command.ExecuteNonQuery();
  
  // result gives the -1 output.. but on insert its 1
  using (SqlDataReader reader = command.ExecuteReader())
  {
      // iterate your results here
      Console.WriteLine(String.Format("{0}",reader["id"]));
  }
  
  conn.Close();
  </code></pre>
  
  <p>The query works fine on SQL Server, but I am not getting why only select query is not working. </p>
  
  <p>All other queries are working.</p>