导航

.net读取二进制流图片

Posted on 2010-10-21 14:11  Trible.H  阅读(1448)  评论(0编辑  收藏  举报

    string conn = ConfigurationManager.AppSettings["ConnectionString"].ToString();
            SqlConnection Connection = new SqlConnection(conn);
            Connection.Open();
            String SqlCmd = "select * from LocationImage where LIIntNo='"+imageid+"' ";
            SqlCommand CmdObj = new SqlCommand(SqlCmd, Connection);

            SqlDataReader SqlReader = CmdObj.ExecuteReader();
            SqlReader.Read();
            Response.ContentType = "image/jpeg";
            Response.OutputStream.Write((byte[])SqlReader["LocImage"], 0, ((byte[])SqlReader["LocImage"]).Length);
            Response.End();
            Connection.Close();