using System; using System.Data; using System.Data.Sql; using System.Data.SqlClient; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class teatevaatamine : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["id"] == null) { //Response.Write("id puudub"); Label1.Text = "id puudub"; return; } try { Label1.Text = Request.QueryString["id"]; SqlConnection toru = new SqlConnection( ConfigurationManager .ConnectionStrings["baas1ConnectionString"] .ConnectionString); SqlCommand kasklus = new SqlCommand( "SELECT pealkiri, teade, aeg FROM ajaveeb " + "WHERE id=@id"); kasklus.Connection = toru; toru.Open(); kasklus.Parameters.AddWithValue("@id", Request.QueryString["id"]); SqlDataReader reader = kasklus.ExecuteReader(); if (reader.Read()) { Page.Title = reader.GetString(0); Label1.Text = reader.GetString(0); Label2.Text = reader.GetString(1); Label3.Text = reader.GetDateTime(2).ToString(); } else { Label1.Text = "Kirje puudub"; } toru.Close(); } catch (Exception ex) { Label1.Text = "Vigane päring"; //Label1.Text = ex.ToString(); } } }