代码如下:if (dt.Rows[0]["photo"].ToString() != "")
{
    byte[] image = (byte[])(dt.Rows[0]["photo"]);
    if (image.Length > 0)
    {
        this.Response.Clear();
        this.Response.BinaryWrite(image);
        this.Response.End();
    }
}

解决方案 »

  1.   

    byte[] image = (byte[])(dt.Rows[0]["photo"]);
    if (image.Length>0)
    {
        System.IO.MemoryStream ms = new MemoryStream(image);
        System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(ms);
        this.Response.Clear();
        bmp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
        this.Response.End();
        ms.Close();
    }
      

  2.   

    或者:
    byte[] image = (byte[])(dt.Rows[0]["photo"]);
    if (image.Length>0)
    {
    System.IO.MemoryStream ms = new System.IO.MemoryStream(image);
    this.Response.ContentType = "image/Jpeg";
    ms.WriteTo(this.Response.OutputStream);
    ms.Close();
    }
      

  3.   

    好奇怪,我是第一次遇到这个问题,你写的方法也不管用
    还是只在页面上输出 System.Byte[]
      

  4.   

    Response.ContentType = "image/jpg"; 
    byte[] photo = (byte[])Reader1["userPhoto"]; 
     if(photo.Length != 0)           
          Response.BinaryWrite(photo); 
    图片类型可保存时保存
           
      

  5.   

    Response.ContentType = Reader1["imgType"].ToString(); 
      

  6.   


    那估计你存入数据库中时候就是这个“System.Byte[]”字符串了
      

  7.   

    Reader1["imgType"].ToString(); 
    这个imgType是什么?
      

  8.   

    byte[] image = (byte[])(dt.Rows[0]["photo"]);
    if (image.Length > 20)
    {
      // 看一下 image 到底是什么:
      Response.Write(System.BitConverter.ToString(image, 0, 20));
    }
      

  9.   

    53-79-73-74-65-6D-2E-42-79-74-65-5B-5D
    如上为转换结果...
    图片是存在的...
      

  10.   

    53-79-73-74-65-6D-2E-42-79-74-65-5B-5D
    刚好就是:
    System.Byte[]
    参考:
      

  11.   

    说明你保存到数据库中的是:53-79-73-74-65-6D-2E-42-79-74-65-5B-5D,也就是:Systme.Byte[] 这个字符串。
      

  12.   

    也就是说:你显示图片的代码没问题,但是保存图片到数据库中的代码有问题,把任何图片都保存为 
    0x53797374656D2E427974655B5D 了,你可以打开数据库看一下就明白了。
      

  13.   

    我怀着满腔的感激想回复你,但是csdn老是报错。
    帖子结掉了,如果你还能看到我的回复的话~
    我想说谢谢你wuyi8808,分析的很透彻...
      

  14.   

    唉 ,我都照着各位大神 的方法去做了。。怎么输出的都是 System.Byte[]~~~蛋疼地飘过。。