By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,758 Members | 1,223 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,758 IT Pros & Developers. It's quick & easy.

Arguments Exceptions pls help T.T

P: 1
Hi im currently trying to figure out the problem of a code with IHttphandler

<%@ WebHandler Language="vb" Class="ShowImage" %>

Imports System
Imports System.Configuration
Imports System.Web
Imports System.IO
Imports System.Data
Imports System.Data.SqlClient

Public Class ShowImage
Implements IHttpHandler
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
Dim picid As Int32
If Not context.Request.QueryString("id") Is Nothing Then
picid = Convert.ToInt32(context.Request.QueryString("id"))
Throw New ArgumentException("No parameter specified")
End If

context.Response.ContentType = "image/jpeg"
Dim strm As Stream = ShowAlbumImage(picid)
Dim buffer As Byte() = New Byte(4095){}
Dim byteSeq As Integer = strm.Read(buffer, 0, 4096)

Do While byteSeq > 0
context.Response.OutputStream.Write(buffer, 0, byteSeq)
byteSeq = strm.Read(buffer, 0, 4096)
End Sub

Public Function ShowAlbumImage(ByVal picid As Integer) As Stream
Dim conn As String = ConfigurationManager.ConnectionStrings("albumConnS tring").ConnectionString
Dim connection As SqlConnection = New SqlConnection(conn)
Dim sql As String = "SELECT pic FROM Album WHERE Pic_ID = @ID"
Dim cmd As SqlCommand = New SqlCommand(sql, connection)
cmd.CommandType = CommandType.Text
cmd.Parameters.AddWithValue("@ID", picid)
Dim img As Object = cmd.ExecuteScalar()
Return New MemoryStream(CType(img, Byte()))
Return Nothing
End Try
End Function

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

End Class

i actually tired alot of other codes found in other web sites n ALL of them didnt work out properly.. (since last two weeks)
After i debug the code above with aspx, an error poped up on the End IF below the Throw New Arguments Exception..
mind explaining wat happening to me n how can i solve the problem??

thx for reading : )
Sep 27 '08 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 533
Hi there,

Firstly, welcome to Please be sure to take a read through the Posting Guidelines and FAQs.

Secondly, I've moved your thread to the .NET Forum as the ASP Forum is for classic ASP (v3.0 with VBScript/JScript)-related questions.

Many thanks,

Sep 28 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.