Solved

Image Loading in ASP.NET

Posted on 2003-11-01
6
248 Views
Last Modified: 2010-04-17
The way I Load images read from a database is first reading the image as binary stream and eventually Response.BinaryWrite to a page and then load the page as the image src of the aspx page.

Is there a more efficient way of loading images rather first loading to a page and then laoding the page ?
0
Comment
Question by:Anurudda
  • 2
6 Comments
 

Accepted Solution

by:
sberkovitz earned 68 total points
ID: 9664134
byte[] imageBytes = GetImageDataFromSomewhere();

Response.ContentType = "image/jpeg" // or whatever type the image is
Response.OutputStream.Write(imageBytes, 0, imageBytes.Length);
Response.End();

0
 
LVL 1

Assisted Solution

by:net99online
net99online earned 67 total points
ID: 9667401
You Can get your image directly using Image datatype
you must first include the namespace which include the Image class

1-from the Data Toolbox make a SQLCommand and put in it the select statment

2-in its parameters define the image parameter let it "@image_par" and for its SqlDbType choose the "Image" Datatype

3- change the dirction property to "Output"

4-excute the procedure, this must be done before you get the value

5-you can get the image Like This :

Image img = (image) sqlCommand1.parameters["@image_par"]
note: the image must be stored in bitmap format

please inform me for any questions
0
 
LVL 1

Expert Comment

by:net99online
ID: 9667416
please add this step

in the parameter you add be sure to type in the SourceColoumn property the Column in the database which includes the image data
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

Suggested Solutions

Title # Comments Views Activity
count8 challlenge 13 120
allStar challenge 1 52
VB6 Compile Compatibility Issue 4 90
Java Loop 6 50
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

863 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

26 Experts available now in Live!

Get 1:1 Help Now