|
<%@ WebHandler Language="C#" Class="Handler" %>
using System;
using System.Data;
using System.Web;
using System.Data.SqlClient;
using System.IO;
public class Handler : IHttpHandler {
public void ProcessRequest (HttpContext context) {
SqlConnection myConnection = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\Database.mdf;Integrated Security=True;User Instance=True");
myConnection.Open();
string sql = "Select Image_Content from ImageGallery where Img_Id=@ImageId";
SqlCommand cmd = new SqlCommand(sql, myConnection);
cmd.Parameters.Add("@ImageId",SqlDbType.Int).Value =Convert.ToInt32(context.Request.QueryString["id"]);
cmd.Prepare();
SqlDataReader dr = cmd.ExecuteReader();
dr.Read();
context.Response.ContentType = "jpeg";//dr["Image_Type"].ToString();
context.Response.BinaryWrite((byte[])dr["Image_Content"]);
}
public bool IsReusable {
get {
return false;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.