本文介绍了从文件夹和数据库中读取图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用 asp.net vb 代码从数据库中的文件夹images"和她的名字中读取图像这是我使用的代码.
Dim conn As SqlConnectionDim cmd 作为 SqlCommandDim cmdString As String = ("select TOP 20 * from tbl_news order by db_id desc ")conn = New SqlConnection("Data Source=.\sqlexpress;AttachDbFilename=C:\Users\m7md\Documents\Visual Studio 2008\Projects\AlAkhbar\AlAkhbar\App_Data\Database1.mdf;Integrated Security=True;User Instance=True")cmd = 新建 SqlCommand(cmdString, conn)连接.Open()Dim dr As SqlDataReader = cmd.ExecuteReader虽然(读博士)Response.Write("")Response.Write("<img src='images/db_img')/>")Response.Write("</div>")Response.Write("")Response.Write(dr("db_title"))Response.Write("
")Response.Write("
")Response.Write("</div>")Response.Write("")Response.Write(dr("db_sumury"))Response.Write("</div>")Response.Write("")Response.Write("<a href=readmore.aspx?id=" & dr("db_id").ToString & "> Readmore</a>")Response.Write("</div>")Response.Write("
")结束时间 解决方案 您需要创建一个图像处理程序.您可以在此处找到更多信息:
- ASP.NET [图像处理程序]
- 动态渲染 ASP:来自 ASP 中 BLOB 条目的图像.网络
- http://www.codeproject.com/Articles/33310/C-Save-and-Load-Image-from-Database
- http://aspalliance.com/1322_Displaying_Images_in_ASPNET_Using_HttpHandlers.5
How can i read images from folder "images" and her name in the database using asp.net vb codethis is the code i use.
Dim conn As SqlConnection
Dim cmd As SqlCommand
Dim cmdString As String = ("select TOP 20 * from tbl_news order by db_id desc ")
conn = New SqlConnection("Data Source=.\sqlexpress;AttachDbFilename=C:\Users\m7md\Documents\Visual Studio 2008\Projects\AlAkhbar\AlAkhbar\App_Data\Database1.mdf;Integrated Security=True;User Instance=True")
cmd = New SqlCommand(cmdString, conn)
conn.Open()
Dim dr As SqlDataReader = cmd.ExecuteReader
While (dr.Read)
Response.Write("<div id=title>")
Response.Write("<img src='images/db_img') />")
Response.Write("</div>")
Response.Write("<div id=title>")
Response.Write(dr("db_title"))
Response.Write("<br/>")
Response.Write("<br/>")
Response.Write("</div>")
Response.Write("<div id=sumury>")
Response.Write(dr("db_sumury"))
Response.Write("</div>")
Response.Write("<div id=readmore>")
Response.Write("<a href=readmore.aspx?id=" & dr("db_id").ToString & "> Readmore</a>")
Response.Write("</div>")
Response.Write("<hr/>")
End While
解决方案 You need to create an image handler. You can find more information here:
- ASP.NET [Image Handler]
- Dynamically Rendering asp:Image from BLOB entry in ASP.NET
- http://www.codeproject.com/Articles/33310/C-Save-and-Load-Image-from-Database
- http://aspalliance.com/1322_Displaying_Images_in_ASPNET_Using_HttpHandlers.5
这篇关于从文件夹和数据库中读取图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-02 14:10