title: Connecting to SQL Server in ASP.NET
body: <p>I am trying to connect to the SQL Server from Visual Web Developer using asp.net but I am facing some problems If anybody helps in this regard i will be greatful.</p>
  <pre><code>public partial class _Default : Page
  {
      protected void Page_Load(object sender, EventArgs e)            
      {     
          SqlConnection conn = new SqlConnection(&quot;Server=localhost;&quot; + &quot;Database=DB;User ID=aaaa;&quot; + &quot;Password=aaaa&quot;);
  
          conn.Open(); SqlDataReader reader = conn.ExecuteReader(); 
          while (reader.Read()) {
              employeesLabel.Text += reader[&quot;Name&quot;] + &quot;&lt;br /&gt;&quot;;
          }
          reader.Close(); 
          conn.Close();               
      }
  }
  </code></pre>
  <p>I am getting errors saying</p>
  <blockquote>
  <p>'System.Data.SqlClient.SqlConnection' does not contain a definition for <strong>'ExecuteReader'</strong> and no extension method 'ExecuteReader' accepting a first argument of type 'System.Data.SqlClient.SqlConnection' could be found (are you missing a using directive or an assembly reference?)</p>
  <p>The name '<strong>employeesLabel</strong>' does not exist in the current context.</p>
  </blockquote>
  <p>Can anybody tell the possible reason?</p>