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 trykk2 : 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 "+ "FOR XML RAW('koer'), elements, ROOT('loetelu')", cn); cn.Open(); SqlDataReader lugeja = cm.ExecuteReader( CommandBehavior.CloseConnection); lugeja.Read(); Response.AddHeader("Content-type", "text/xml"); Response.Write(lugeja.GetString(0) + "\n"); } }