using System; using System.Collections; using System.Linq; using System.Web; using System.Web.Services; using System.Web.Services.Protocols; using System.Xml.Linq; using System.Data.OleDb; using System.Data.Odbc; /// /// Summary description for korrapidajaotsing /// [WebService(Namespace = "http://tempuri.org/")] [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 korrapidajaotsing : System.Web.Services.WebService { public korrapidajaotsing () { //Uncomment the following line if using designed components //InitializeComponent(); } [WebMethod] public string HelloWorld() { return "Hello World"; } [WebMethod] public string KorrapidajaVastavaltKuupaevale(int kuupaev) { string[] korrapidajad = { "Juku", "Kati", "Mati" }; return korrapidajad[kuupaev % 3]; } [WebMethod] public string SportlasteLoetelu(int minsynniaasta) { OdbcConnection cn = new OdbcConnection("DRIVER={Microsoft Access Driver (*.mdb)};" + "DBQ="+Server.MapPath("~\\App_Data\\baas1.mdb")+"; Trusted Connection=true"); OdbcCommand cm = new OdbcCommand("SELECT eesnimi, synniaasta FROM sportlased", cn); cn.Open(); OdbcDataReader lugeja = cm.ExecuteReader(); XElement juur = new XElement("sportlased"); while (lugeja.Read()) { XElement isik = new XElement("sportlane"); XElement en = new XElement("eesnimi", lugeja.GetString(0)); XElement sa = new XElement("synniaasta", lugeja.GetInt32(1)); isik.Add(en); isik.Add(sa); juur.Add(isik); } return juur.ToString(); } }