title: Executing SQL query from C# code
body: <p>I'm trying to execute SQL query from C# code, but it doesn't return any values, but when I write query directly to SQL it works fine.</p>
  
  <pre><code>static int TestGettingData()
  {
          int rows;
          string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
          using (SqlConnection connection = new SqlConnection(connectionString))
          {
              using (SqlCommand command = new SqlCommand("SELECT [UserName] FROM [aspnet_Users]", connection))
              {
                  connection.Open();
                  rows = command.ExecuteNonQuery();
              }
          }
          return rows;
  }
  </code></pre>
  
  <p>And connection string: </p>
  
  <pre><code>&lt;connectionStrings&gt;
  &lt;add name ="DefaultConnection" connectionString="Server=myServer;
              Database=MyDatabase;User 
              Id=User;
              Password=password;
              MultipleActiveResultSets=True;"
              providerName="System.Data.SqlClient"/&gt;
  &lt;/connectionStrings&gt;
  </code></pre>
  
  <p>And <code>TestGettingData()</code> always returning -1.</p>