Calling ASP.NET Web Service Using Jquery - Part III - Fetch Data From SQL Server

11. March 2010 01:29

ASP.NET Jquery  2 Comments

My previous two posts on using Jquery for calling ASP.NET web service takes you to the basics of calling a web service using Jquery AJAX. In this last post of the series I will show hot to fetch data from the SQL Server through a web service.

In this example I am going to show on how we can fetch data from SQL Server. I am using pretty well known Adventure Works database for this example. I am using Person.Contact table for this example. I will show on how to fetch data i.e. first name, last name and e-mail address on the basis of the ContactID.
So first, as usual create a normal ASP.NET project and add the required files. Create a new web service, I have named my web service “AdvService.asmx”. You can name your web service as you like. This time we are fetching data from the SQL Server by passing a parameter to the web service method. I am using the very same, basic way of fetching record from the SQL Server. You can also use LINQ here to fetch data.

I have used a delay of few seconds to how the animation, rest in the code is self explanatory. Just passing a parameter and fetching the details of the person from the Adventure Works database.Below are the screenshots for the sample application.

Download: (97.86 kb)

Currently rated 5.0 by 7 people

Comments (2)

Gobinath Gobinath
1/25/2012 10:37:57 AM #

hai prashant u sample is nice.i followed ur steps but iam getting an internal server to correct it wat wil the problem

Prashant Prashant
1/25/2012 9:13:13 PM #

Are you using the same code sample as provided above? I suggest you to re-check the parameters you are passing in the [i]data[/i] tag and also make sure that the connection string is correct.

Add Comment

Visit to discover Indian blogs Computers Blogs