|
<%@ WebHandler Language="C#" Class="ShowFullSizeImg" %>
using System;
using System.Web;
public class ShowFullSizeImg : IHttpHandler {
public void ProcessRequest (HttpContext context) {
Int32 idNo;
if (context.Request.QueryString["id"] != null)
idNo = Convert.ToInt32(context.Request.QueryString["id"]);
else
throw new ArgumentException("No parameter specified");
context.Response.ContentType = "image/jpeg";
System.IO.Stream strm = ShowEmpImage(idNo);
byte[] buffer = new byte[4096];
int byteSeq = strm.Read(buffer, 0, 4096); //4094
while (byteSeq > 0)
{
context.Response.OutputStream.Write(buffer, 0, byteSeq);
byteSeq = strm.Read(buffer, 0, 4096);
}
}
private System.IO.Stream ShowEmpImage(int userId)
{
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
System.Data.SqlClient.SqlConnection connection = new System.Data.SqlClient.SqlConnection(conn);
string sql = "SELECT ImageFull From dbo.[User] WHERE UserId = @userId";
System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(sql, connection);
cmd.CommandType = System.Data.CommandType.Text;
cmd.Parameters.AddWithValue("@userId", userId);
connection.Open();
object img = cmd.ExecuteScalar();
try
{
return new System.IO.MemoryStream((byte[])img);
}
catch
{
return null;
}
finally
{
connection.Close();
}
}
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.
MCTS - Microsoft Certified Technology Specialist.
An Accountant.
Had been developed Payroll Accounting System Application
Live in: Quezon City, Metro Manila Philippines
Could reached at email address: ag_mojedo@live.com