Solved

How to retrieve an image from sql server database to an asp.net table control ?

Posted on 2009-07-08
4
236 Views
Last Modified: 2012-05-07
In my project I am using the following manner to retrieve the images from database ...

Private Sub GenerateTableData(ByVal orgid As Integer)
        Dim str As String
        Dim cmd As New SqlCommand
        Dim conn As New SqlConnection(connStr)
        conn.Open()
        str = "Select productid, productname from tblproduct WHERE originid=" & orgid
        Try
            cmd = New SqlCommand(str, conn)
            Dim dtr As New SqlDataAdapter(cmd)
            Dim dst As New DataSet
            dst.Clear()
            dtr.Fill(dst, "po")
            Dim tr As TableRow
            Dim td As TableCell
            Dim i, j As Integer
            For i = 0 To dst.Tables(0).Rows.Count - 1
                tr = New TableRow
                td = New TableCell
                td.Width = 167
                td.HorizontalAlign = HorizontalAlign.Center
                td.VerticalAlign = VerticalAlign.Middle
                Dim prodId As Integer = dst.Tables(0).Rows(i).Item(0)
                td.Text = "ABC" & "<asp:Image ID='Image" & i & "' runat='server' ImageUrl='imgGrab.aspx?tab=tblproduct&showfld=smallimage&condfld=productid&id=" & prodId & "' ImageAlign='middle' />"
                tr.Cells.Add(td)
                Table1.Rows.Add(tr)
            Next
        Catch ex As Exception
            Throw
        Finally
            conn.Close()
        End Try

My Output is :
ABC
ABC
(As only 2 records in the table)
But no image is showing in the table. If I copy paste the code of image control directly in the page it is showing the image. so i think my ImgGrab.aspx is working fine.
will you pls help me in this regard ???
its urgent ...
0
Comment
Question by:akulavi
  • 3
4 Comments
 
LVL 21

Expert Comment

by:Tapan Pattanaik
ID: 24801457
0
 

Author Comment

by:akulavi
ID: 24801470
I am following ur links... but it will be helpful for me if u pls rectify my code which i had already stated above...... because the same code if I am using in an image control it is showing me the image , but if I write the code as the text of of TableCell control then it is not showing ...
0
 

Author Comment

by:akulavi
ID: 24801478
Moreover, My requirement is very specific ..... whether we can use the tablecell's text as I had stated earlier or we cannot use the image control..... If yes then whether my way is ok or not ....
0
 

Accepted Solution

by:
akulavi earned 0 total points
ID: 24801698
I have solved my problem using the <img >control of html.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now