Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Retrieve image from SQL Server using vb.net

Posted on 2013-06-19
4
Medium Priority
?
318 Views
Last Modified: 2013-08-15
I have tried probably 10 different ways to get my .net application to display the images that are stored on my SQL server as type "image".  The latest attempt is from this web site.  I used the vb code.  The uploaded images save in the database and have the proper size, but when it comes time to retrieve them, I get back only the broken image symbol.  Debugging does not show any errors.  Can anyone figure out why this would be?  (As an aside, I cannot for the life of me figure out why clicking the submit button causes the submission to happen twice!)
0
Comment
Question by:tdisher
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 11

Expert Comment

by:SAMIR BHOGAYTA
ID: 39261549
hi...

you just have to retrieve images from database through the reader. If you stored image height and width into database so it also you can retrieve with reader and you just write the following code

ltImage.Text = "<img src='../PathofImage/' & reader.item("ImageField")">"
0
 
LVL 35

Expert Comment

by:Robert Schutt
ID: 39265273
I have downloaded the source code (from the dotnetcurry skydrive) and it works when I put it in a simple website. However, I have tried to add it to an existing web project for debugging and failed so maybe you have a similar problem? In that case some more info might be needed to find out what the actual problem is. When I tested it, I made some mistakes with database permissions but since you are seeing the records in the database I guess you've passed that station.

The 'aside' problem you mention (duplicate submit) is also mentioned in the comments on the page: it's ok in the download but from the aspx code posted on the page you have to remove
onclick="btnSubmit_Click"

Open in new window

which is only needed in the C# version, the VB version has this code instead, defined after the Sub:
Handles btnSubmit.Click

Open in new window


I did also see mention of this double submit causing empty image records so it could actually solve your problem?!

If not, can you retrieve an image directly? Try something like ...//your_website_and_path/ShowImage.ashx?id=1
0
 

Author Comment

by:tdisher
ID: 39265969
When I created a completely new web site, the dotnetcurry code worked perfectly.  When I changed the sql to perform the lookup to my production database, it fails.  I have to believe there is something wrong with the data being stored in my production database.  Removing the onclick = did fix the duplicate record issue.
0
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 1500 total points
ID: 39266142
If you're convinced that is the problem you could try using a small picture and copy/pasting the actual value from the table here (to see if that data works when I put it in my database). Although I'm a bit confused by your latest post versus your earlier remark "The uploaded images save in the database and have the proper size". Did you try the last proposal in my previous post?
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

636 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