Solved

Image Loading in ASP.NET

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
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 …

726 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