Note that there are some explanatory texts on larger screens.

plurals
  1. PORetrieve Sql Data Using WebMethod & Jquery
    primarykey
    data
    text
    <p>I wants to retrieve data from sql server using webserver/jquery and I read many articles but not getting the require matters except below but I think It's support FrameWork .Net 3.5 not 2.0. And I have the same requirement to use it in ASP.Net 2.0.</p> <pre><code>//On WebServer Page.. WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [ScriptService] public class test : System.Web.Services.WebService { [WebMethod] public string GetCustomer(string memberID) { string response = "&lt;p&gt;No customer selected&lt;/p&gt;"; string connect = "Server=myserver;Initial Catalog=mydatabase;uid=myuser;pwd=mypassword"; string query = "SELECT name, father, mother from samaj where name=@memberID"; if (memberID != null) { StringBuilder sb = new StringBuilder(); using (SqlConnection conn = new SqlConnection(connect)) { using (SqlCommand cmd = new SqlCommand(query, conn)) { cmd.Parameters.AddWithValue("memberID", memberID); conn.Open(); SqlDataReader rdr = cmd.ExecuteReader(); if (rdr.HasRows) { while (rdr.Read()) { sb.Append("&lt;p&gt;"); sb.Append("&lt;strong&gt;" + rdr["name"].ToString() + "&lt;/strong&gt;&lt;br /&gt;"); sb.Append(rdr["father"].ToString() + "&lt;br /&gt;"); sb.Append(rdr["mother"].ToString() + "&lt;br /&gt;"); response = sb.ToString(); } } } } } return response; } } } //.aspx page... &lt;script type="text/javascript" src="jquery-1.3.2.min.js" &gt;&lt;/script&gt; &lt;script type="text/javascript" &gt; $(document).ready(function(){ $("#Customers").change(function() { $.ajax ({ type: "POST", contentType: "application/json; charset=utf-8", url: "test.asmx/GetCustomer", data: "{ memberID: '" + $('#Customers').val() + "'}", dataType: "json", success: function(data) { $("#CustomerDetails").html(data.d); } }); }); }); &lt;/script&gt; &lt;form id="form1" runat="server"&gt; &lt;div id="SelectCustomers"&gt; &lt;asp:DropDownList ID="Customers" runat="server"&gt; &lt;/asp:DropDownList&gt; &lt;/div&gt; &lt;div id="CustomerDetails"&gt; &lt;/div&gt; &lt;/form&gt; The DropdownList Binding In Default.aspx.cs page... protected void Page_Load(object sender, EventArgs e) { string connect = "Server=myserver;Initial Catalog=mydatabse;uid=myuser;pwd=mypwd string query = "SELECT name FROM samaj"; using (SqlConnection conn = new SqlConnection(connect)) { using (SqlCommand cmd = new SqlCommand(query, conn)) { conn.Open(); Customers.DataSource = cmd.ExecuteReader(); Customers.DataValueField = "name"; Customers.DataBind(); } } </code></pre> <p>.asmx page testing ok It’s retrieves the data well but on client side It’s not return any data. How to achieve it in ASP.Net 2.0?.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload