using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services; using System.Web.Services.Protocols; using System.Data.SqlClient; using System.Data; using System.ComponentModel; namespace CustomerService { /// /// Summary description for Service1 /// [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] // 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 Service1 : System.Web.Services.WebService { [WebMethod] public DataSet GetCustomers() { // Create sqlconnection & sqldataadapter objects to get SqlConnection conn = new SqlConnection(@"Data Source=.;Initial Catalog=Northwind;Integrated Security=True"); SqlDataAdapter da = new SqlDataAdapter("Select * from Customers",conn); DataSet ds = new DataSet(); //Use the data adapter to fill the data set da.Fill(ds, "Customers"); //Return the dataset return ds; } } }