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; using System.Configuration; public partial class pildivaataja : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { SqlConnection cn = new SqlConnection( ConfigurationManager.ConnectionStrings[ "ConnectionString"].ConnectionString); SqlCommand cm = new SqlCommand( "SELECT pildiandmed FROM tegelased WHERE id=@id", cn); cn.Open(); cm.Parameters.AddWithValue("id", Request.QueryString["id"]); Response.ContentType = "image/jpeg"; Response.BinaryWrite((byte[])cm.ExecuteScalar()); } }