我从数据库中读取图片时显示乱码,是怎么回事?请问怎么解决?

解决方案 »

  1.   

    Response.ContentType="image/Png"
    Response.BinaryWrite(objMemoryStream.ToArray())
      

  2.   

    以下就是我的代码:
    string strSQL="select * from resource where resource_id=8";
                string strConn="Password=jj,2727;Persist Security Info=True;User ID=sa;Initial Catalog=fzjx;Data Source=zhh-m";
    SqlConnection myConnection=new SqlConnection(strConn);
    myConnection.Open(); SqlCommand myCommand=new SqlCommand(strSQL,myConnection); SqlDataReader myReader = myCommand.ExecuteReader();
    if(myReader.Read())
    {
    Response.ContentType=myReader["format"].ToString(); //告诉IE文件的MIME类型 Response.OutputStream.Write((byte[])myReader["content"],  0, (int)myReader["length"]);           }