My favorites
▼
|
Sign in
yccodigo
yccodigo
Project Home
Downloads
Wiki
Issues
Source
Repository:
default
wiki
Checkout
Browse
Changes
Clones
Source path:
hg
/
DotNet_Gravar_e_Ler_Imagem_no_Banco_de_dados
/
CSharp_Gravar_e_Ler_Imagem_Banco_de_dados
/
GerarImagem.ashx
9e0e8a2db6b1
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;
}
}
}
Show details
Hide details
Change log
62f9ba5e96c5
by yccodigo on May 2, 2010
Diff
a
Go to:
..._Banco_de_dados/GerarImagem.ashx
..._de_dados/Imagem/ImgGridview.png
..._Imagem_no_Banco_de_dados/README
...gem_no_Banco_de_dados/README.txt
..._Banco_de_dados/GerarImagem.ashx
..._de_dados/Imagem/ImgGridview.png
Project members,
sign in
to write a code review
Older revisions
All revisions of this file
File info
Size: 1388 bytes, 37 lines
View raw file
Powered by
Google Project Hosting