[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

ASP.Net/VB:   thumbnail images from database

Posted on 2006-07-08
10
Medium Priority
?
224 Views
Last Modified: 2006-11-18
I have a sculptor's website to complete, but I'm stuck on the Gallery portion of the site. Due to security and other concerns, the images are stored in a database as BLOB data. Please don't waste your answer on telling me to change it to directory-based storage, okay? I'm just following orders here. Anyway, I have a simple getImage page that will retrieve single images from the SQL db with no problem. (I found the code on the Net somewhere.) The page has no UI, just code I call from an 'OpenArt' page, using the following code to set the image URL for an <asp:image> tag:  imgArt.imageURL = "../getImg.aspx?id=1"

In the gallery there is a list of art pieces, each being an <asp:hyperlink>. When the user clicks a link, I grab the imgID from a session variable, enabling the user to see the piece's image, the price, et cetera.

Well, the artist now wants thumbnail images instead of hyperlinks. That blows my system out of the water.

NOTE: storing thumbnails in the database is not an option. The artist must be able to maintain the site herself, and she lacks the skills to make her own thumbnail images. Thumbnails must be made on the fly in this case.

I can't get the getImg.aspx page to respond to anything I pass in the queryString, and I don't understand the '?id=1' part of the URL (getImg.aspx?id=1) I use to call the page. Where does this 'id' come from? Right now I'm using a session variable to provide the imgID for the db retrieval sproc (note the indented line below). This obviously won't work for multiple images on a single Gallery page. I've tried no less than 20 links around the Net to try to figure this out, and I'm just tired of it. Thanks for any help I can get.

Here's the code for getImg.aspx:

'--------------------BEGIN CODE--------------

Sub Page_load()
 dim objConn as sqlConnection
 dim objCmdGetImg as sqlCommand
 dim strConn as string = ConfigurationSettings.AppSettings("dbConnStr")
 dim rdrGetImg as sqlDataReader
 objConn = new sqlConnection(strConn)
 objConn.open
 Try
  objCmdGetImg = new sqlCommand("db_getImg", objConn)
  objCmdGetImg.commandType = commandType.storedProcedure

                 objCmdGetImg.Parameters.Add("@imgID", sqlDBType.bigint).value = Session("imgID")

  rdrGetImg = objCmdGetImg.executeReader(CommandBehavior.CloseConnection)
  if rdrGetImg.hasRows then
   Do While rdrGetImg.Read
    Response.ContentType = rdrGetImg.Item(0)
    Response.BinaryWrite(rdrGetImg.Item(1))
   Loop
   rdrGetImg.close
   objCmdGetImg.dispose
  end if
 Catch SQLexc As SqlException
  Response.Write("Read Failed : " & SQLexc.ToString())
 End Try
End Sub

'--------------------END CODE--------------
0
Comment
Question by:k3n51mm
[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
  • 3
  • 2
10 Comments
 
LVL 14

Accepted Solution

by:
Ramuncikas earned 1000 total points
ID: 17067327
In case you use session variable:
objCmdGetImg.Parameters.AddWithValue("@imgID", Session("imgID"))

In case you use query string (like getImg.aspx?id=1):
objCmdGetImg.Parameters.AddWithValue("@imgID", Request.QueryString.Item("id"))
0
 
LVL 12

Assisted Solution

by:deanvanrooyen
deanvanrooyen earned 1000 total points
ID: 17067369
this is how you create a thumbnail from an image - not sure how to read it from the db , havent done that yet - is is into some sort of stream? when you create the bitmap you can pass a stream to the constructor

using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;

                        Bitmap b = new Bitmap(stream);
                        Image im = b.GetThumbnailImage( 100, 100,  new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);

        public bool ThumbnailCallback()
        {
            return true;
        }

then in in a grid
0
 
LVL 12

Expert Comment

by:deanvanrooyen
ID: 17306124
if he needs help with the stream read and seroalization let me know hopefully, he was helped a bit
0
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.

 
LVL 12

Expert Comment

by:deanvanrooyen
ID: 17315020
thanks
0
 
LVL 14

Expert Comment

by:Ramuncikas
ID: 17323817
No objections
Thanks
0
 
LVL 1

Author Comment

by:k3n51mm
ID: 17335639
Sure, go ahead and split it, thx
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

649 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