Solved

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

Posted on 2009-07-08
4
240 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Reading the Web.Config using IIS 7.5? 4 36
VB.Net - KeyPress Event 4 36
Need help with building query string 2 19
insert value of checklistbox checked 4 27
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

770 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