using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.Sql; using System.Data.SqlClient; public partial class trykk3 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { SqlConnection cn = new SqlConnection( "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\Database.mdf;Integrated Security=True;User Instance=True"); SqlCommand cm = new SqlCommand( "SELECT koeranimi, synniaasta FROM koerad " + "WHERE synniaasta>@v2himaasta "+ "FOR XML RAW('koer'), elements, ROOT('loetelu')", cn); int v2him = 0; if (Request.QueryString["v2him"] != null) { int.TryParse(Request.QueryString["v2him"], out v2him); } cm.Parameters.AddWithValue("v2himaasta", v2him); cn.Open(); SqlDataReader lugeja = cm.ExecuteReader( CommandBehavior.CloseConnection); if (lugeja.Read()) { Response.AddHeader("Content-type", "text/xml"); Response.Write(lugeja.GetString(0) + "\n"); } else { Response.Write("Andmed puuduvad"); } } }