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
38
<%@ WebHandler Language="VB" Class="GerarImagem" %>

Imports System
Imports System.Web
Imports System.Data.SqlClient
Imports System.Data

Public Class GerarImagem : Implements IHttpHandler

Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
If String.IsNullOrEmpty(context.Request.QueryString("id")) Then
context.Response.ContentType = "text/plain"
context.Response.Write("Está faltando a querystring id.")
Else
context.Response.ContentType = "image/jpg"
Dim conexao As New SqlConnection(ConfigurationManager.ConnectionStrings("SqlConnectionStringSqlServer").ConnectionString)
Try
conexao.Open()
Dim comando As 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(comando.ExecuteScalar)
Catch ex As Exception

Finally
conexao.Close()
End Try
End If
End Sub

Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Get
Return False
End Get
End Property

End Class

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: 1519 bytes, 38 lines
Powered by Google Project Hosting