I used the code below in a .ashx generic handler page to display a pdf file.
The code below was retrieving a file that was saved in the database as a varbinary(max) datatype.
I want to do this again and the only difference this time is the file is saved in the database as an image datatype.
Do I have to alter the code to retrieve data stored as an image datatype???
public void ProcessRequest(HttpContext ctx)
string id = ctx.Request.QueryString["id"];
SqlConnection con = new SqlConnection("connection string here");
SqlCommand cmd = new SqlCommand("SELECT File FROM tblFiles where FileId = @fileID", con);
cmd.CommandType = CommandType.Text;
byte pict = (byte)cmd.ExecuteScalar();
ctx.Response.ContentType = HttpContext.Current.Session["fileExtension"].ToString();
ctx.Response.OutputStream.Write(pict, 0, int.Parse(pict.Length.ToString()));