Response.BinaryWrite expects an argument of type Byte Array.
Just off the top of my head, I'd say you need to convert that item
somehow (I'd spend time doing more research but between my multiple jobs
and my newborn second child, I'm a tad short on time :).

Cheers,

Peter

-----Original Message-----
From: harpie22 [mailto:[EMAIL PROTECTED] 

I am trying to read a Image File stream using ASP.net

here is the code i am getting a error

Private Sub SHowImage(ByVal Student As String)
        Dim PhotoSeek As String
        PhotoSeek = "select Photo from Patron where Student=892497"
        Dim objConn As New FbConnection
        objConn.ConnectionString 
= "Database=C:\Inetpub\wwwroot\FireConnect\cafeterm.fdb;User=SYSDBA;Pa
ssword=masterkey;Dialect=3;Server=localhost;Pooling=False"
        objConn.Open()
        Dim objCMD As New FbCommand(PhotoSeek, objConn)
        Dim pa As FbDataReader
        pa = objCMD.ExecuteReader
        If pa.Read() Then
            Response.ContentType = "image/gif"
            Response.BinaryWrite(pa.Item(0))

        End If


    End Sub



this is the error


Server Error in '/FireConnect' Application.
----------------------------------------------------------------------
----------

Specified cast is not valid. 
Description: An unhandled exception occurred during the execution of 
the current web request. Please review the stack trace for more 
information about the error and where it originated in the code. 

Exception Details: System.InvalidCastException: Specified cast is not 
valid.

Source Error: 


Line 83:         If pa.Read() Then
Line 84:             Response.ContentType = "image/gif"
Line 85:             Response.BinaryWrite(pa.Item(0))
Line 86: 
Line 87:         End If
 

Source File: C:\Inetpub\wwwroot\FireConnect\WebForm1.aspx.vb    Line: 
85 

Stack Trace: 


[InvalidCastException: Specified cast is not valid.]
   FireConnect.WebForm1.SHowImage(String Student) in 
C:\Inetpub\wwwroot\FireConnect\WebForm1.aspx.vb:85
   FireConnect.WebForm1.Button1_Click(Object sender, EventArgs e) in 
C:\Inetpub\wwwroot\FireConnect\WebForm1.aspx.vb:71
   System.Web.UI.WebControls.Button.OnClick(EventArgs e)
   
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.R
aisePostBackEvent(String eventArgument)
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler 
sourceControl, String eventArgument)
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
   System.Web.UI.Page.ProcessRequestMain()





------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to