title: how to connect with database using jquery in asp.net
body: <p>I want to display some fields from database using jquery.this is the code for connecting database and display</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $(document).ready(function () {
          $('#btnsearch').click(function () {
              $.ajax({
                  type: "POST",
                  contentType: "application/json; charset=utf-8",
                  data: "{ CustomerID: '" + $('#txtid').val() + "'}",
                  url: "Customer.aspx/FetchCustomer",
                  dataType: "json",
                  success: function (data) {
                      var Employee = data.d;
                      $('#CustomerDetails').append
                        ('&lt;p&gt;&lt;strong&gt;' + Employee.Id + "&lt;/strong&gt;&lt;br /&gt;" +
                        Employee.fname + "&lt;br /&gt;" +
                        Employee.lname + "&lt;br /&gt;" +
                         "&lt;/p&gt;")
                  }
              });
          });
      });
  &lt;/script&gt;
  </code></pre>
  
  <hr>
  
  <p>.cs code</p>
  
  <pre><code>[WebMethod]
      public Employee FetchCustomer(string employeeId)
      {
          Employee c = new Employee();
          SqlConnection con = new SqlConnection("Data Source=BAIJU-PC;Initial      Catalog=Baiju;Integrated Security=True");
          // SqlDataAdapter da = new SqlDataAdapter("select * from emp wher id='" + employeeId + "'", con);
          con.Open();
          SqlCommand cmd = new SqlCommand("select * from emp wher id='" + employeeId + "'", con);
          SqlDataReader dr = cmd.ExecuteReader();
          while (dr.Read())
          {
              c.id = dr["id"].ToString();
              c.fname = dr["fname"].ToString();
              c.lname = dr["LNAME"].ToString();
          }
  
          return c;
      }
      public class Employee
      {
          public string id { get; set; }
          public string fname { get; set; }
          public string lname { get; set; }
  
      }
  </code></pre>
  
  <p>error is when I run the application .cs code is firing it executes upto this code</p>
  
  <pre><code>SqlDataReader dr = cmd.ExecuteReader();
  </code></pre>
  
  <p>after this it is not executing.
  how to solve this problem</p>