<% '动态加载节日弹窗 dim rsimage,image,displayDate set rsimage=server.CreateObject("ADODB.recordset") image= "" ssql1 = "select image,usingdate from OA_IMAGE where usingdate>='" & CurrDate & "' and (delete_flag<>'*' or delete_flag is null )" 'Response.Write ssql1 rsimage.Open ssql1,Conn_oracleIn,1,1 if not rsimage.EOF then 'image=rsimage("image") 'displayDate=rsimage("usingdate") response.write "<script language='javascript'>javascript:gotourl('image.aspx','','','','',false);</script>" %> <% end if rsimage.Close %>
image.aspx
using System; using System.Collections.Generic; using System.Data; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class image : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { get_photo(); } } /// <summary> /// 将图片从数据库中读取 /// </summary> public void get_photo() { string ssql1 = "select image,usingdate from OA_IMAGE where usingdate>='" + DateTime.Now.ToString("yyyy-MM-dd") + "' and (delete_flag<>'*' or delete_flag is null )"; DataSet ds = DBHelper_Ip.Query(ssql1); if (ds.Tables[0].Rows.Count > 0) { //将,以前的多余字符串删除 string base64String = ds.Tables[0].Rows[0]["image"].ToString(); string strbase64 = base64String.Trim().Substring(base64String.IndexOf(",") + 1); byte[] imagebytes = Convert.FromBase64String(strbase64); Response.Clear(); Response.ContentType = "image/png;"; Response.BinaryWrite(imagebytes); Response.Flush(); Response.End(); } } }