My favorites | Sign in
Project Home Downloads Wiki Issues Source
Repository:
Checkout   Browse   Changes   Clones    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<%@ WebHandler Language="C#" Class="GerarImagem" %>

using System;
using System.Web;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;

public class GerarImagem : IHttpHandler {

public void ProcessRequest (HttpContext context) {
if(string.IsNullOrEmpty(context.Request.QueryString["id"])) {
context.Response.ContentType = "text/plain";
context.Response.Write("Está faltando a querystring id.");
} else {
context.Response.ContentType = "image/jpeg";
SqlConnection conexao = new SqlConnection(ConfigurationManager.ConnectionStrings["SqlConnectionStringSqlServer"].ConnectionString);
try {
conexao.Open();
SqlCommand comando = new SqlCommand("SELECT Imagem FROM DotNet_Gravar_e_Ler_Imagem_no_Banco_de_dados WHERE IDImagem = @IDImagem", conexao);
comando.CommandType = CommandType.Text;
comando.Parameters.Add("@IDImagem", SqlDbType.Int).Value = context.Request.QueryString["id"];
context.Response.Clear();
context.Response.BinaryWrite((byte[])comando.ExecuteScalar());
} finally{
conexao.Close();
}
}
}

public bool IsReusable {
get {
return false;
}
}

}

Change log

62f9ba5e96c5 by yccodigo on May 2, 2010   Diff
a
Go to: 
Project members, sign in to write a code review

Older revisions

All revisions of this file

File info

Size: 1388 bytes, 37 lines
Powered by Google Project Hosting