using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.Sql; using System.Data.SqlClient; public partial class leht1 : 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"); cn.Open(); SqlCommand cm = new SqlCommand( "SELECT mark, aasta FROM autod " + "FOR XML RAW('masin'), ROOT('masinad'), ELEMENTS", cn); String vastus=cm.ExecuteScalar().ToString(); Response.ContentType = "text/xml"; Response.Write(""); Response.Write(vastus); Response.End(); } }