Solved

Image Loading in ASP.NET

Posted on 2003-11-01
6
247 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

RIA (Rich Internet Application) tools are interactive internet applications which have many of the characteristics of desktop applications. The RIA tools typically deliver output either by the way of a site-specific browser or via browser plug-in. T…
This article will show, step by step, how to integrate R code into a R Sweave document
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 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…

771 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

10 Experts available now in Live!

Get 1:1 Help Now