<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<%@ Import Namespace="System.IO" %>
<script language="C#" runat="server">
void Page_load(object Sender, EventArgs E) {
MemoryStream stream = new MemoryStream();
SqlConnection connection;
connection = new SqlConnection("server=localhost;database=pubs;uid=sa;pwd=");
try {
connection.Open();
SqlCommand command;
command = new SqlCommand("select logo from pub_info where pub_id=\’0736\’", connection);
byte[] image;
image = command.ExecuteScalar();
stream.Write(image, 0, image.Length);
bitmap imgbitmap;
imgbitmap = new Bitmap(stream);
Response.ContentType = "image/gif";
imgbitmap.Save(Response.OutputStream, ImageFormat.Gif);
}
finally {
connection.Close();
stream.Clse();
}
}
</script>
MemoryStream stream = new MemoryStream(); string constr = System.Configuration.ConfigurationSettings.AppSettings["SQLConnectionString"]; string slct="select imageSrc from dbo.image_excise where id=1"; SqlConnection scon = new SqlConnection(constr); //string slct = "select ThemeFileData from SPS_M_ThemeFile where ThemeFileCD=" + imgid; SqlCommand scmd = new SqlCommand(slct,scon); scon.Open(); SqlDataReader sdr = scmd.ExecuteReader(); Response.ContentType = "image/jpeg"; if(sdr.Read()) { if(((byte[])sdr.GetValue(0)).Length != 0) { Response.BinaryWrite((byte[])sdr.GetValue(0)); return; } } try { FileStream fs = new FileStream(Server.MapPath("Images/Image_NoPicture.gif"),FileMode.Open,FileAccess.Read); byte[] mydata = new byte[fs.Length]; int Length = Convert.ToInt32(fs.Length); fs.Read(mydata,0,Length); fs.Close(); this.Response.OutputStream.Write(mydata,0,Length); } catch(Exception ex) { return; } sdr.Close(); scon.Close(); this.Response.End();
写
HtmlInputFile[] tempfile = new HtmlInputFile[3]; tempfile[0] =this.imageFile1; tempfile[1] =this.imageFile2; tempfile[2] =this.imageFile3;//16011 for(int i=0;i<3;i++) { byte[] buff = new byte[tempfile[i].PostedFile.ContentLength]; tempfile[i].PostedFile.InputStream.Read(buff,0,tempfile[i].PostedFile.ContentLength); try { System.Drawing.Image img = System.Drawing.Image.FromStream(new System.IO.MemoryStream(buff)); } catch { return ; } SqlParameter[] spr = new SqlParameter[2]; spr[0]=new SqlParameter("@imageTitle",SqlDbType.NVarChar); spr[0].Value="test"+i.ToString(); spr[1] = new SqlParameter("@imageSrc",SqlDbType.Image); spr[1].Value = buff; SqlHelper.ExecuteNonQuery(SqlHelper.dsn,CommandType.StoredProcedure,"imageInsert",spr); }
发表评论
-
转载:jquery webservice 跨域
2013-01-28 16:06 1254现在的JQuery中$.ajax方法支持跨域读取json数 ... -
excel 导入导出
2011-10-27 10:32 834excel 导入导出 -
仿google 日历
2011-08-24 23:10 866仿google 日历仿google 日历仿google 日历仿 ... -
DataTime.ToString("xx")
2011-08-12 13:57 1150//2008年4月24日 System.DateTi ... -
ASP.Net 文件上传大小限制IIS7
2011-08-11 09:41 2657ASP.Net 文件上传大小限制解决方案修改IIS7/ ... -
Request
2011-07-12 17:08 930Request.params、Request、Request. ... -
ASP.NET MVC 第五回 ActionResult的其它返回值
2011-06-21 15:38 1800ASP.NET MVC 第五回 ActionResult的 ... -
dbhelper table扩展
2011-06-15 11:00 691dbhelper table扩展 -
C#扩展对象的方法,this关键字
2011-06-15 10:58 1200namespace ConsoleApplication2 ... -
asp.net mvc2.0的Areas多级文件夹问题
2011-06-15 10:53 1319此文只写给遇到同样问题的人看的,因此写得会有点短 ... -
WCF实例(基于TCP协议的配置)
2011-01-10 17:52 1081WCF实例(基于TCP协议的配置) 启动ServerHost ... -
反射机制
2010-06-24 09:39 828反射的定义:审查元 ... -
委托线程
2010-06-24 09:37 767本系列教程主要包括如下内容:1. BeginInvoke ... -
asp.net 自定义web控件
2008-11-11 15:34 832<%@ Register TagPrefix=&quo ... -
PDF-activereport
2008-09-11 13:36 1445using System; using System.Coll ... -
xml read -write -update -remove
2008-08-19 14:05 989<?xml version="1.0" ... -
read file directory
2008-08-13 09:31 771using System; using System.Coll ... -
web。config
2008-06-27 10:41 763一、认识Web.config文件 网管下载dl.bitscn. ... -
Application,Session,Cookie,ViewState,Cache
2008-06-26 18:20 1591Application 1. Applicat ... -
构造数据源
2008-06-25 13:23 823DataTable dgTable2=new DataTabl ...
相关推荐
易语言记录集读写图片数据源码,记录集读写图片数据
易语言源码易语言记录集读写图片数据源码.rar 易语言源码易语言记录集读写图片数据源码.rar 易语言源码易语言记录集读写图片数据源码.rar 易语言源码易语言记录集读写图片数据源码.rar 易语言源码易语言记录集...
通过二进制数据流的方式,读写图片,把图片存入数据库,再从数据库读取出来显示
资源介绍:。易语言记录集组件读写图片数据源码。资源作者:。资源界面:。资源下载:。
往MYSQL中插入,读写图片!主要是利用java代码往mysql插入图片,再读出来显示在网页上!
C#二进制图片的读写 vs2005 sql
易语言SQL图片读写源码,SQL图片读写
通过http://www.vbsqlite.com.ar/archive/file.php?id=28 ...上面的例子进行改进,测试通过了VB+Sqlite3.dll文件进行数据库基础操作和读写图片文件,非com控件,无需注册,采用unicode,省去了UTF8编码的麻烦!
易语言记录集读写图片数据源码
有分的,送我1分,没有分的,PM我,不用分也一样给你下载。 这个例子教你如何将图片以二进制的格式保存进ACCESS数据库里。再教你怎样读出来。 保证能用,不帅不用钱!
适于VC初学者,简单实现图像的读写,主要是对BMP格式图像的读写,流程是用一个对话框打开图片再将图片读入Doc里,然后再显示
NULL 博文链接:https://seaie.iteye.com/blog/1678004
MySQL读写改例子
数据图片读写器
易语言记录集组件读写图片数据源码 三叶自学网
VS.NET2005开发平台中,使用XML文件读写图像文件。