?
Solved

ASP.Net/VB:   thumbnail images from database

Posted on 2006-07-08
10
Medium Priority
?
223 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

777 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