ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Consume Json Web Service in ASP.Net using C# and VB.Net<p>Hi <a class="username" rel="nauna"> nauna</a>,</p> <p>Refer below articles</p> <ol style="list-style-type: undefined;"> <li class="header"><a title="Perform HTTP POST to REST WCF Service (SVC) in ASP.Net using C# and VB.Net'a" href="https://www.aspsnippets.com/Articles/Perform-HTTP-POST-to-REST-WCF-Service-SVC-in-ASPNet-using-C-and-VBNet.aspx" target="_blank">Perform HTTP POST to REST WCF Service (SVC) in ASP.Net using C# and VB.Net</a></li> <li><a id="lnkTitle" href="https://www.aspsnippets.com/Articles/Call-Consume-REST-WCF-Service-SVC-using-HttpWebRequest-in-ASPNet-with-C-and-VBNet.aspx" target="_blank">Call (Consume) REST WCF Service (SVC) using HttpWebRequest in ASP.Net with C# and VB.Net </a></li> <li><a id="lnkTitle" href="https://www.aspsnippets.com/Articles/Call-Consume-REST-WCF-Service-SVC-using-WebClient-in-ASPNet-with-C-and-VBNet.aspx" target="_blank">Call (Consume) REST WCF Service (SVC) using WebClient in ASP.Net with C# and VB.Net </a></li> <li><a id="lnkTitle" href="https://www.aspsnippets.com/Articles/Call-Consume-WCF-Service-SVC-using-AJAX-in-ASPNet.aspx" target="_blank">Call (Consume) WCF Service (SVC) using AJAX in ASP.Net</a></li> </ol>https://www.aspforums.net:443/Threads/109489/Consume-Json-Web-Service-in-ASPNet-using-C-and-VBNet/https://www.aspforums.net:443/Threads/109489/Consume-Json-Web-Service-in-ASPNet-using-C-and-VBNet/Wed, 14 Jun 2017 03:08:41 GMTConsume Json Web Service in ASP.Net using C# and VB.Net<p>hi,</p> <p>&nbsp;</p> <p>I reviewed all the links it does not have what i asked for,</p> <p>&nbsp;</p> <p>my webservice is ok i just need to know that how can i fetch data from sql server and return the values please see my question again thanks</p>https://www.aspforums.net:443/Threads/109489/Consume-Json-Web-Service-in-ASPNet-using-C-and-VBNet/https://www.aspforums.net:443/Threads/109489/Consume-Json-Web-Service-in-ASPNet-using-C-and-VBNet/Wed, 14 Jun 2017 03:24:52 GMTConsume Json Web Service in ASP.Net using C# and VB.Net<p><a href="http://www.c-sharpcorner.com/article/generate-json-data-using-web-service-and-sql-server-stored-procedure/">http://www.c-sharpcorner.com/article/generate-json-data-using-web-service-and-sql-server-stored-procedure/</a></p> <p>&nbsp;</p> <p>i want some thing like this but this tutorial is very complex and using store procedure i want sql statement in web service instead of store procedure</p>https://www.aspforums.net:443/Threads/109489/Consume-Json-Web-Service-in-ASPNet-using-C-and-VBNet/https://www.aspforums.net:443/Threads/109489/Consume-Json-Web-Service-in-ASPNet-using-C-and-VBNet/Wed, 14 Jun 2017 04:35:15 GMTConsume Json Web Service in ASP.Net using C# and VB.Net<p>Hi <a class="username" rel="nauna">nauna</a>,</p> <p>I have created a sample which full fill your requirement you need to modify the code according to your need.</p> <p>I have used Northwind Database Customers Table you can get Database from below link.</p> <p><a id="lnkTitle" href="https://www.aspsnippets.com/Articles/Install-the-Northwind-and-Pubs-Sample-Databases-in-SQL-Server-Express.aspx" target="_blank">Install the <span class="Highlight">Northwind</span> and Pubs Sample Databases in SQL Server Express </a></p> <p>Refer below Sample Code.</p> <p><strong><span style="text-decoration: underline;">WebService.asmx</span></strong></p> <pre class="brush: html">&lt;%@ WebService Language=&#34;C#&#34; CodeBehind=&#34;~/App_Code/WebService.cs&#34; Class=&#34;WebService&#34; %&gt;</pre> <p><strong><span style="text-decoration: underline;">WebService.cs</span></strong></p> <pre class="brush: csharp">using System.Collections.Generic; using System.Web.Services; using System.Data.SqlClient; using System.Configuration; using System.Web.Script.Serialization; /// &lt;summary&gt; /// Summary description for WebService /// &lt;/summary&gt; [WebService(Namespace = &#34;http://tempuri.org/&#34;)] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. [System.Web.Script.Services.ScriptService] public class WebService : System.Web.Services.WebService { [WebMethod] public string GetCustomers() { List&lt;object&gt; customers = new List&lt;object&gt;(); string sql = &#34;SELECT TOP 10 CustomerId,ContactName,Country FROM Customers&#34;; using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString = ConfigurationManager.ConnectionStrings[&#34;constr&#34;].ConnectionString; using (SqlCommand cmd = new SqlCommand(sql)) { cmd.Connection = conn; conn.Open(); using (SqlDataReader sdr = cmd.ExecuteReader()) { while (sdr.Read()) { customers.Add(new { CustomerId = sdr[&#34;CustomerId&#34;], ContactName = sdr[&#34;ContactName&#34;], Country = sdr[&#34;Country&#34;] }); } } conn.Close(); } return (new JavaScriptSerializer().Serialize(customers)); } } }</pre> <p><strong><span style="text-decoration: underline;">HTML</span></strong></p> <pre class="brush: html">&lt;div&gt; &lt;table id=&#34;tblCustomers&#34;&gt; &lt;/table&gt; &lt;/div&gt; &lt;div&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;https://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.3/jquery.min.js&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34;&gt; $(function () { $.ajax({ type: &#34;POST&#34;, url: &#34;WebService.asmx/GetCustomers&#34;, data: &#34;&#34;, contentType: &#34;application/json; charset=utf-8&#34;, dataType: &#34;json&#34;, success: function (r) { $(&#39;[id*=tblCustomers]&#39;).append(&#34;&lt;tr&gt;&lt;th&gt;CustomerId&lt;/th&gt;&lt;th&gt;ContactName&lt;/th&gt;&lt;th&gt;Country&lt;/th&gt;&lt;/tr&gt;&#34;); $.each($.parseJSON(r.d), function (key, value) { var customerId = value.CustomerId; var contactName = value.ContactName; var country = value.Country; $(&#39;[id*=tblCustomers]&#39;).append(&#34;&lt;tr&gt;&lt;td&gt;&#34; + customerId + &#34;&lt;/td&gt;&lt;td&gt;&#34; + contactName + &#34;&lt;/td&gt;&lt;td&gt;&#34; + country + &#34;&lt;/td&gt;&lt;/tr&gt;&#34;); }); }, error: function (r) { alert(r.responseText); }, failure: function (r) { alert(r.responseText); } }); }); &lt;/script&gt; &lt;/div&gt;</pre> <p><strong><span style="text-decoration: underline;">Output</span></strong></p> <table border="1"> <tbody> <tr> <td><strong>CUSTOMERID</strong></td> <td><strong>ContactName</strong></td> <td><strong>Country</strong></td> </tr> <tr> <td>AAFKM</td> <td>Mudassar Khan</td> <td>Belgium</td> </tr> <tr> <td>ALFKI</td> <td>Maria</td> <td>Austria</td> </tr> <tr> <td>ANATR</td> <td>Ana Trujillo</td> <td>France</td> </tr> <tr> <td>ANTON</td> <td>Antonio Moreno</td> <td>Brazil</td> </tr> <tr> <td>AROUT</td> <td>Thomas Hardy</td> <td>Ireland</td> </tr> <tr> <td>BERGS</td> <td>Christina Berglund</td> <td>Italy</td> </tr> <tr> <td>BLAUS</td> <td>Hanna Moos</td> <td>Finland</td> </tr> <tr> <td>BLONP</td> <td>Fr&eacute;d&eacute;rique Citeaux</td> <td>Finland</td> </tr> <tr> <td>BOLID</td> <td>Mart&iacute;n Sommer</td> <td>Argentina</td> </tr> <tr> <td>BONAP</td> <td>Laurence Lebihan</td> <td>USA</td> </tr> </tbody> </table> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/109489/Consume-Json-Web-Service-in-ASPNet-using-C-and-VBNet/https://www.aspforums.net:443/Threads/109489/Consume-Json-Web-Service-in-ASPNet-using-C-and-VBNet/Thu, 15 Jun 2017 04:45:24 GMT