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 --------------------~-->
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/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/