using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.Sql; using System.Data.SqlClient; public partial class andmeloetelu2 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { SqlConnection yhendus = new SqlConnection( "Data Source=.\\SQLEXPRESS;AttachDbFilename=D:\\kasutaja\\jaagup\\andmedxml1\\App_Data\\Database.mdf;Integrated Security=True;User Instance=true"); SqlCommand kask = new SqlCommand( "SELECT id, koeranimi, synniaasta " + "FROM koerad " + "WHERE synniaasta>=@synd FOR XML RAW('koer')," + " root('koerteloetelu'), ELEMENTS", yhendus); kask.Parameters.AddWithValue("synd", Request["minaasta"]); yhendus.Open(); String vastus = kask.ExecuteScalar() as String; Response.ContentType = "text/xml"; Response.Write(""); if (vastus != null) { Response.Write(vastus); } else { Response.Write("Andmed puuduvad"); } Response.End(); } }