如何在ASPX网页中的SQL Server数据库和显示中加载已保存的图像 [英] How Do I Load Saved Image in SQL Server Database and Display in ASPX webpage

查看:97
本文介绍了如何在ASPX网页中的SQL Server数据库和显示中加载已保存的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

全部,



需要帮助才能显示保存在SQL Server数据库中的图片图像并在图像控件对象中显示相同的图片。



这是我在硬盘上显示图像文件时使用的代码,但我需要一个直接从SQL Server数据库文件中的图像字段加载图像。

All,

Need assistance in displaying picture image saved in SQL Server Database and display same in Image control object.

This is the code I used in displaying image file from hard-disk but I need one to load image directly from image field in SQL Server Database file.

Protected Sub btnDisplayPassport_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDisplayPassport.Click
    If Not FileUpload1.HasFile Then
        Label1.Text = "You have not uploaded a file."
    ElseIf CheckExtension(FileUpload1.FileName) = False Then
        Label1.Text = "Only .gifs, and .jpgs, please."
    Else
        Session("strUploadedFile") = Server.MapPath("~/images/") & FileUpload1.FileName
        Image2.Visible = True
        Try
            FileUpload1.SaveAs(Server.MapPath("~/images/") & FileUpload1.FileName)
            Session("sstrPassportFile") = FileUpload1.FileName
            Label1.Text = FileUpload1.FileName
            Dim strServerpath As String
            strServerpath = Server.MapPath("~/images/")
            Image2.ImageUrl = "thumbnailer.ashx?file=" & Server.UrlEncode(FileUpload1.FileName)
        Catch exc As Exception
            Label1.Text = "There was a problem: " & exc.Message
        End Try
    End If
End Sub

推荐答案

Hello Sam,



这里有这个网站上的一些文章你会觉得很有用。

Hello Sam,

Here are few articles from this very site which you shall find useful.

  • Save and Retrieve Image from a SQL Server Database using VB.NET[^]
  • C# Save and Load Image from Database[^]
  • Auto-bind byte[] to asp:Image[^]
  • SQL Database Image Storage & Easy Thumbnails*[^]
  • Binary streaming of large images from Database*[^]


从本文中获得解决方案 http://www.dotnetcurry.com/ShowArticle.aspx?ID=129 [ ^ ]
Got the solution from this article http://www.dotnetcurry.com/ShowArticle.aspx?ID=129[^]


从此获得解决方案文章

http://www.dotnetcurry.com/ShowArticle.aspx?ID=129 [ ^ ]
Got the solution from this article
http://www.dotnetcurry.com/ShowArticle.aspx?ID=129[^]


这篇关于如何在ASPX网页中的SQL Server数据库和显示中加载已保存的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆