0

I'm having a trouble with displaying my image from the database(i'm using sql server 2008) It says "Could not create type 'LeaveApplication.EmployeePhoto'."

Employee.aspx

  <asp:Image ID="empPic" runat="server" Height="200px" ImageUrl="~/Images/pic.jpg" Width="200px" /></div>

Employee.aspx.vb

Dim ses As String ses = Session("ses_empNum") txtEmployeeNum.Text = ses

'empPic.ImageUrl = "../usrcontrols/EmployeePhoto.ashx?EmpNum'" & ses & "'"
empPic.ImageUrl = "../usrcontrols/EmployeePhoto.ashx?id=idkey'" & ses & "'"

EmplpyeePhoto.ashx.vb

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

Public Class PatientPhoto
    Implements System.Web.IHttpHandler

    Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest


        Dim ID As New String(context.Request.QueryString("ID"))

        Dim sqlConn As New SqlConnection("server=192.168.6.7;uid=sa;pwd=da;database=payroll_hospital;multipleactiveresultsets=true")
        sqlConn.Open()

        ID = Replace(ID, "^", "'")
        Dim sqlComm As New SqlCommand("select dbImage from patient_data.dbo.tbdbImage where " & ID, sqlConn)
        'context.Response.Write)
        'Exit Sub

        'context.Session.Item("test") = "select dbImage from patient_data.dbo.tbdbImage where " & ID

        Dim dr As System.Data.SqlClient.SqlDataReader

        dr = sqlComm.ExecuteReader
        If dr.Read Then
            context.Response.BinaryWrite(dr.Item("dbImage"))
        Else
            'Response.Write("File Not Found.")
            context.Response.Write("<img src=../images/blank.jpg>")
        End If
        sqlConn.Close()



    End Sub

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

End Class

Employee.ashx

1 Answer 1

1

I bet you renamed a code class somewhere but did not update the code behind page. The code behind page does not know what the name is when it changes by hand.

Look for somewhere where you modified the class name.

public MyChangedClass:Page{} 

<%@ CodeBehind="MyChangedClass.aspx.cs" Class="MyOldClassName" %>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.