2007-10-17

ASP.NET热点问题解答14个

来源: 本站收集整理 作者: 评论 0 条
 

message.To = "web3@163.com"

message.Subject = "测试"

message.Body = "内容"

Mail.SmtpMail.SmtpServer = "localhost"

Mail.SmtpMail.Send(message)

14、我将如何通过ADO.NET读取数据库中的图片并显示它呢?

下面举一个从Microsoft SQL Server的PUB数据库读取图片并显示它的例子:

<%@ 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>


共3页: 上一页 [1] [2] 3 下一页

(本文仅表明作者个人观点,不代表本站及其管理员立场.) 推荐 收藏 投稿 打印 返回 关闭
上一篇:ASP向ASP.AET 环境迁移需要考虑的问题  
下一篇:MySQL与ASP.NET配合
    评论加载中…
 推荐文章
     

网站首页  -  网站地图 -   站长论坛  -  网站投稿  -    -  网站管理
Copyright © 2008 芜湖站长站 All Rights Reserved 皖ICP备07500611号