Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
VB
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
Posted
Updated 27-Jun-13 6:38am
v2
Comments
[no name] 27-Jun-13 12:30pm    
Okay.... and? What sort of "assistance" do you need? Have you tried anything? Can you connect to your database? Can you execute a query? Can you get the image out of the database?

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

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900