System.Byte[] Photo = (byte[])ds.Tables[0].Rows[0]["VclImage"];
Response.OutputStream.Write(Photo, 0, Photo.Length);
Response.BinaryWrite(Photo); 使用这两种方法都不行造成图片乱码了
请问是什么原因?

解决方案 »

  1.   

    因为你没有输出图片的类型,光有流是不行的
    Response.ContentType = "image/pjpeg";
      

  2.   

    string strId = Request.QueryString["id"].ToString() ;
    DataSet dsCount = new DataSet() ;
    dsCount = (new DACommonFunctionSystem()).GetDataSetBySql("select count(*) as a from vehicleimage where VclImageID=" + strId) ;
    if(Convert.ToInt32(dsCount.Tables[0].Rows[0]["a"])!=0)
    {
    DataSet ds = new DataSet() ;
    ds = (new DACommonFunctionSystem()).GetDataSetBySql("select * from vehicleimage where VclImageID=" + strId) ;//查取对应的图片信息
    System.Byte[] Photo = (byte[])ds.Tables[0].Rows[0]["VclImage"];
    Response.ContentType="image/pjpeg"; 
    Response.OutputStream.Write(Photo, 0, Photo.Length);
    Response.End(); 
    }
    else
    {}那为大哥帮忙给小弟说说,要加个Image控件代码怎么该
      

  3.   

    先前我是显示在页面上,也达到效果了,
    但是现在出现问题了,如果不显示在控件中,在显示时出现一个下载对话筐
    所以我加上一个控件,不知道该怎么控制了
    ================================================
    你用你输出的方法输到一个页面中。然后把Image控件的URL指向这个也就行了。
      

  4.   

    一个问题开两帖:
    byte[]   b=new   byte[1];   
      System.Data.SqlClient.SqlDataReader   dr=cm.ExcuteDataReader();   
      if(dr.read())   
      {   
      b=(byte[])dr["imagefield"];   
      }   
      System.IO.MemoryStream   ms=new   System.IO.MemoryStream();   
      ms.Write(b,0,b.Length-1);   
      this.Image1.ImageUrl=new   System.Drawing.Bitmap(ms);