0

我在显示数据库中的图像时遇到问题(我使用的是 sql server 2008)它说“无法创建类型 'LeaveApplication.EmployeePhoto'。”

员工.aspx

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

员工.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

员工.ashx

4

1 回答 1

1

我敢打赌,您在某处重命名了代码类,但没有更新页面后面的代码。页面后面的代码在手动更改时不知道名称是什么。

寻找修改类名的地方。

public MyChangedClass:Page{} 

<%@ CodeBehind="MyChangedClass.aspx.cs" Class="MyOldClassName" %>
于 2014-06-27T02:26:29.380 回答