QEDDave2022
New member
- Joined
- Mar 18, 2022
- Messages
- 4
- Programming Experience
- 10+
Hello and think you for your time ... I have been fighting this and viewing waaayyy to many code examples because I don't see what's wrong with the following even given I am not that smart. VS error code BC30149.
My code ...
Imports System.Web
Imports System.Web.Services
Imports System.Data.SqlClient
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Drawing.Color
Imports System.IO
Imports System.Drawing.Printing
Imports System.Globalization
Imports System.Linq
Public Class ImageHandler
Implements System.Web.IHttpHandler
ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Get
Return False
End Get
End Property
Public Sub ProcessRequest(ByVal context As HttpContext)
Dim imageId As String = context.Request.QueryString("Id").ToString()
Dim con As SqlConnection = New SqlConnection("Data Source=DESKTOP-6TI2MH9\SQLEXPRESS2017;Initial Catalog=Images;Integrated Security=True;Persist Security Info=False")
Dim cmd As SqlCommand = New SqlCommand("select Image from Images where id=" & imageId, con)
con.Open()
Dim dr As SqlDataReader = cmd.ExecuteReader()
dr.Read()
context.Response.BinaryWrite(CType(dr(0), Byte()))
context.Response.ContentType = "image/jpg"
context.Response.[End]()
End Sub
End Class
It's called from a button click event
My code ...
Imports System.Web
Imports System.Web.Services
Imports System.Data.SqlClient
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Drawing.Color
Imports System.IO
Imports System.Drawing.Printing
Imports System.Globalization
Imports System.Linq
Public Class ImageHandler
Implements System.Web.IHttpHandler
ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Get
Return False
End Get
End Property
Public Sub ProcessRequest(ByVal context As HttpContext)
Dim imageId As String = context.Request.QueryString("Id").ToString()
Dim con As SqlConnection = New SqlConnection("Data Source=DESKTOP-6TI2MH9\SQLEXPRESS2017;Initial Catalog=Images;Integrated Security=True;Persist Security Info=False")
Dim cmd As SqlCommand = New SqlCommand("select Image from Images where id=" & imageId, con)
con.Open()
Dim dr As SqlDataReader = cmd.ExecuteReader()
dr.Read()
context.Response.BinaryWrite(CType(dr(0), Byte()))
context.Response.ContentType = "image/jpg"
context.Response.[End]()
End Sub
End Class
It's called from a button click event