Solved

Image Loading in ASP.NET

Posted on 2003-11-01
6
249 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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

809 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