Asp.net(c#)将数据库中以二进制存的图片显示出来
来源:互联网 发布:淘宝电脑端详情页视频 编辑:程序博客网 时间:2024/05/06 07:05
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.IO;
using System.Drawing;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
SqlConnection con = new SqlConnection("server=(local);user id=sa;pwd=;database=库名");
SqlDataAdapter ada = new SqlDataAdapter("select * from tb_17 ", con);
con.Open();
DataSet ds = new DataSet();
ada.Fill(ds);
DropDownList1.DataSource = ds;
DropDownList1.DataTextField = "字段";
DropDownList1.DataValueField = "字段";
DropDownList1.DataBind();
Image1.Visible=false;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Image1.Visible = true;
SqlConnection con = new SqlConnection("server=(local);user id=sa;pwd=;database=库名");
string imagename = "";
try
{
con.Open();
SqlCommand com = new SqlCommand("select name from 表名 where 字段="+DropDownList1.Text+"", con);
SqlDataReader dr = com.ExecuteReader();
dr.Read();
MemoryStream ms = new MemoryStream((Byte[])dr["name"]);
Bitmap image = new Bitmap(ms);
string filepath = Server.MapPath("Files/");
DirectoryInfo dir = new DirectoryInfo(filepath);
FileInfo[] filecount = dir.GetFiles();
int i = filecount.Length;
imagename = filepath + ((i + 1) + ".jpg");
image.Save(imagename);
dr.Close();
Image1.ImageUrl = "Files/" + ((i + 1) + ".jpg");
}
finally
{
con.Close();
}
}
}
- Asp.net(c#)将数据库中以二进制存的图片显示出来
- ASP.NET(C#) 实现将图片以二进制保存到数据库中
- ASP.NET(C#) 实现将图片以二进制保存到数据库中 转
- ASP.net(c#)将图片以二进制格式存储到数据库中
- Asp.net将图片以二进制数据存进数据库全过程
- Asp.net将图片以二进制数据存进数据库全过程
- asp.net(c#)实现从sql数据库中下载以二进制方式存储的图片
- 以二进制码形式将图片存到数据库中,再从数据库中以二进制的形式从数据库中读出来
- ASP.NET中让图片以二进制的形式存储在数据库中
- ASP.NET中让图片以二进制的形式存储在数据库中
- ASP.NET中让图片以二进制的形式存储在数据库中
- ASP.NET中让图片以二进制的形式存储在数据库中
- ASP.NET中让图片以二进制的形式存储在数据库中
- ASP.NET中让图片以二进制的形式存储在数据库中
- 将图片以二进制的格式存储到数据库中
- 将数据库 二进制流 图片数据 显示出来
- C# 用二进制将图片保存在数据库里再读出来显示在pictureBox中
- ASP.Net将图片以二进制方式存入数据库,并读取
- 64位汇编移植小结
- 从底层角度看ASP.NET-A low-level Look at the ASP.NET Architecture
- Asp.net必须掌握的一些东西(1)
- Zend Framework 1.10.1 理解和使用 Zend 表单装饰器之一:介绍
- WCF RIA 服务 (二十六)-- Silverlight 客户端 7
- Asp.net(c#)将数据库中以二进制存的图片显示出来
- 最简单的方法去掉iframe滚动条
- Zend Framework 1.10.1 理解和使用 Zend 表单装饰器之二:装饰器基础
- 收购Positivo,让世界都“联想”
- RMAN duplicate 错误越来越离奇!
- 怎么样才能成功录制脚本用LoadRunner9.5
- CPU卡中T=0通讯协议的分析与实现
- 请不要错过身边爱你的人
- WCF RIA 服务 (二十七)-- Silverlight 客户端 8