我在SQL2000中表info_HandOverCar 中字段carPicture 为 IMAGE类型,我在ASP。NET中读图片的代码如下:
        Dim myConnection As New SqlConnection
        myConnection.ConnectionString = ConfigurationSettings.AppSettings("connectionstring")
        Dim myCommand As New SqlCommand
        Dim myReader As SqlDataReader
        myCommand.Connection = myConnection
        myCommand.CommandText = "select carPicture from info_HandOverCar where BookID='" & thisId & "' order by BookID"
        Try
            myConnection.Open()
        Catch ex As Exception
            Session("ErrorMsg") = "<TABLE cellSpacing=0 cellPadding=0 width=750 border=0 align=center><tr><td width=748> <TABLE cellSpacing=1 cellPadding=1 width=505 border=0 align=center bgcolor=CCDAF8> <tr> <td bgcolor=white> <TABLE cellSpacing=1 cellPadding=1 width=100% border=0 align=center> <tr> <td bgcolor=EDF2FC height=24 class=p4 colspan=2>&nbsp;<FONT color=2F59BB><B>错误信息提示</B></FONT> </td> </tr> <tr> <td height=20> </td> </tr> <tr> <td width=35% align=right><IMG SRC=""pic/mistakertu.gif"" WIDTH=""134"" HEIGHT=""129"" BORDER=0 ALT=""""></td> <td class=p5 align=center><font color=red><B>查询错误</B></font><BR><BR></td> </tr> <tr> <td height=20> </td> </tr> </table> </td> </tr> </table><BR><BR><BR>"
            Response.Redirect("ErrorInfo.aspx")
            Server.ClearError()
            Exit Sub
        End Try
        Try
            myReader = myCommand.ExecuteReader
        Catch ex As Exception
            Session("ErrorMsg") = "<TABLE cellSpacing=0 cellPadding=0 width=750 border=0 align=center><tr><td width=748> <TABLE cellSpacing=1 cellPadding=1 width=505 border=0 align=center bgcolor=CCDAF8> <tr> <td bgcolor=white> <TABLE cellSpacing=1 cellPadding=1 width=100% border=0 align=center> <tr> <td bgcolor=EDF2FC height=24 class=p4 colspan=2>&nbsp;<FONT color=2F59BB><B>错误信息提示</B></FONT> </td> </tr> <tr> <td height=20> </td> </tr> <tr> <td width=35% align=right><IMG SRC=""pic/mistakertu.gif"" WIDTH=""134"" HEIGHT=""129"" BORDER=0 ALT=""""></td> <td class=p5 align=center><font color=red><B>查询错误</B></font><BR><BR></td> </tr> <tr> <td height=20> </td> </tr> </table> </td> </tr> </table><BR><BR><BR>"
            Response.Redirect("ErrorInfo.aspx")
            Server.ClearError()
            Exit Sub
        End Try
        While myReader.Read
            '  Response.BinaryWrite(byte(myReader.Item("carPicture")))
            Dim image As Byte() = myReader.Item("carPicture")
            Dim memStream As New System.IO.MemoryStream(image)
            Dim bm As New Bitmap(memStream)
            Response.BinaryWrite(image)
        End While
        myReader.Close()
        myConnection.Close()提示的错误信息为:
指定的转换无效。 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.InvalidCastException: 指定的转换无效。源错误: 
行 72:         While myReader.Read
行 73:             '  Response.BinaryWrite(byte(myReader.Item("carPicture")))
行 74:             Dim image As Byte() = myReader.Item("carPicture")
行 75:             Dim memStream As New System.IO.MemoryStream(image)
行 76:             Dim bm As New Bitmap(memStream)
 源文件: C:\Inetpub\wwwroot\MotorVehicleRepair\CarAlarmPicturedipose.aspx.vb    行: 74 
各位大哥大姐帮忙分析解决一下,好吗?不胜感激 或QQ交流:378566009