//上传图片………………
if (this.FileUpload1.HasFile)
        {
            Stream mystream = FileUpload1.PostedFile.InputStream;
            int length = FileUpload1.PostedFile.ContentLength;            byte[] bytes = new byte[length];
            mystream.Read(bytes, 0, length);
            mystream.Close();
            SqlConnection conn = new SqlConnection(stcon);
            conn.Open();
            string str = "insert into info (photo) values( ' " + bytes + " ') ";
            SqlCommand comm = new SqlCommand(str, conn);
            comm.ExecuteNonQuery();
            conn.Close();
            Response.Write("<script language=javascript>alert('上传成功!')</script>");
        }
//显示图片………………
try
        {
            //string imgtype = FileUpload1.PostedFile.ContentType; 
            SqlConnection conn = new SqlConnection(stcon);
            string sql = "select imgtype,photo from info where IDCard='" + Session["id"].ToString() + "'";
            SqlCommand command = new SqlCommand(sql, conn);
            conn.Open();
            SqlDataReader dr = command.ExecuteReader();
            if (dr.Read())
            {                //Response.ContentType = dr["imgtype"].ToString();
                Response.BinaryWrite((byte[])dr["photo"]);
            }
            else
            {                Response.Write("没有从数据库中读取图片 ");
            }
            conn.Close();
        }
        catch (Exception x)
        {        }