从Microsoft SQL Server的PUB数据库读取图片并显示它
2004-11-16 23:02
585 查看
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<%@ Import Namespace="System.IO" %>
<script language="VB" runat="server">
Sub Page_load(Sender as Object, E as EventArgs)
dim stream as new MemoryStream
dim connection as SqlConnection
connection=new SqlConnection("server=localhost;database=pubs;uid=sa;pwd=")
try
connection.Open()
dim command as SqlCommand
command = new SqlCommand ("select logo from pub_info where pub_id='0736'", connection)
dim image as byte()
image = command.ExecuteScalar ()
stream.Write (image, 0, image.Length)
dim imgbitmap as bitmap
imgbitmap = new Bitmap (stream)
Response.ContentType = "image/gif"
imgbitmap.Save (Response.OutputStream, ImageFormat.Gif)
Finally
connection.Close()
stream.Clse()
End Try
End Sub
</script>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<%@ Import Namespace="System.IO" %>
<script language="VB" runat="server">
Sub Page_load(Sender as Object, E as EventArgs)
dim stream as new MemoryStream
dim connection as SqlConnection
connection=new SqlConnection("server=localhost;database=pubs;uid=sa;pwd=")
try
connection.Open()
dim command as SqlCommand
command = new SqlCommand ("select logo from pub_info where pub_id='0736'", connection)
dim image as byte()
image = command.ExecuteScalar ()
stream.Write (image, 0, image.Length)
dim imgbitmap as bitmap
imgbitmap = new Bitmap (stream)
Response.ContentType = "image/gif"
imgbitmap.Save (Response.OutputStream, ImageFormat.Gif)
Finally
connection.Close()
stream.Clse()
End Try
End Sub
</script>
相关文章推荐
- 一个Mysql自动备份脚本
- 用hibernate将类映射到数据库
- 使用Commons-Pool写的数据库连接池
- ASP中各种数据库连接代码
- Is iSQL Plus running
- 在对数据库的操作中使用parameters
- 在SQL中调用COM对象
- 在SQL中调用COM对象
- 万网ORACLE注入漏洞详细手记
- 万网ORACLE注入漏洞详细手记
- 关于Visio2000 Enterprise和Visio for Enterprise Architects版本中数据库模型的翻译错误!
- SQL函数调用
- 用Sql语句生成Sqlserver数据字典
- SQL 2005 数据库镜像
- 利用存储过程来消除数据库中冗余的数据
- 封装游标存储过程(Pr_execsql2)
- 利用XML实现通用WEB报表打印
- ADO 与ADO.NET
- SQL语法查询文档
- sql相关子查询,动态交叉表篇