Newweb

You might also like

You are on page 1of 2

using

using
using
using
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Web;
System.Web.Services;
System.Data.SqlClient;
System.Data;
System.Configuration;

namespace WebApplication43
{/// <summary>
/// Summary description for WebService
/// </summary>
[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, u
ncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class WebService : System.Web.Services.WebService
{
SqlConnection MyConn = new SqlConnection();
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
//[WebMethod]
//public string GetTotalMember()
//{
//
String ConStr = ConfigurationManager.ConnectionStrings["StrConn"].
ConnectionString;
//
using (SqlConnection Conn = new SqlConnection(ConStr))
//
{
//
using (SqlCommand CMD = new SqlCommand("Select * From Contacts
"))
//
{
//
using (SqlDataAdapter ADP = new SqlDataAdapter())
//
{
//
CMD.Connection = Conn;
//
ADP.SelectCommand = CMD;
//
using (DataTable DTA = new DataTable())
//
{
//
DTA.TableName = "Contacts";
//
ADP.Fill(DTA);
//
return DTA;
//
}
//
}
//
}
//
}
//}
[WebMethod]
public DataTable Get()
{
String ConStr = ConfigurationManager.ConnectionStrings["Con"].Connec
tionString;

using (SqlConnection Conn = new SqlConnection(ConStr))


{
using (SqlCommand CMD = new SqlCommand("Select * From Products")
)
{
using (SqlDataAdapter ADP = new SqlDataAdapter())
{
CMD.Connection = Conn;
ADP.SelectCommand = CMD;
using (DataTable DT = new DataTable())
{
DT.TableName = "Products";
ADP.Fill(DT);
return DT;
}
}
}
}
}
}
}

You might also like