472,954 Members | 2,006 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,954 software developers and data experts.

display images without having them on the disk?

Hello

is it possible to display images on a ASPX without having them on the disk
of the server ?

I have images in a DB and whould like to display them on a web page. writing
them to disk seems very costly.

is it posible to create them in memory and some how give them to the client
to display?

thanks in advance
Yoramo.
Nov 18 '05 #1
5 1630
hi,you can do it just like the following example.

private void Page_Load(object sender, System.EventArgs e)
{
SqlConnection mycon = new SqlConnection("your connection string");
mycon.Open();

int liid = int.Parse(Request.QueryString["id"]);
string sqlText = "SELECT img_name, img_data, img_contenttype FROM image1
where id="+liid;
SqlCommand MyCommand = new SqlCommand (sqlText, mycon);
SqlDataReader dr =MyCommand.ExecuteReader();
if(dr.Read())
{
Response.ContentType = (dr["img_contenttype"].ToString());
Response.BinaryWrite((byte[])dr["img_data"]);
}
mycon.Close();
}
Nov 18 '05 #2
hello

Thanks for your replay.
can you show me how whould the aspx file look like for such a code to
work?

Yoramo.
"white sheng" <wh********@untsoft.com.cn> wrote in message
news:ec***************@tk2msftngp13.phx.gbl...
hi,you can do it just like the following example.

private void Page_Load(object sender, System.EventArgs e)
{
SqlConnection mycon = new SqlConnection("your connection string");
mycon.Open();

int liid = int.Parse(Request.QueryString["id"]);
string sqlText = "SELECT img_name, img_data, img_contenttype FROM image1 where id="+liid;
SqlCommand MyCommand = new SqlCommand (sqlText, mycon);
SqlDataReader dr =MyCommand.ExecuteReader();
if(dr.Read())
{
Response.ContentType = (dr["img_contenttype"].ToString());
Response.BinaryWrite((byte[])dr["img_data"]);
}
mycon.Close();
}

Nov 18 '05 #3
He already did. There is no Template HTML. It simply sends an image. You
include a reference to that page as the URL for an image tag in another
page.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Yoramo" <yoramo@[NOSPAM]hotmail.com> wrote in message
news:#8**************@TK2MSFTNGP10.phx.gbl...
hello

Thanks for your replay.
can you show me how whould the aspx file look like for such a code to
work?

Yoramo.
"white sheng" <wh********@untsoft.com.cn> wrote in message
news:ec***************@tk2msftngp13.phx.gbl...
hi,you can do it just like the following example.

private void Page_Load(object sender, System.EventArgs e)
{
SqlConnection mycon = new SqlConnection("your connection string");
mycon.Open();

int liid = int.Parse(Request.QueryString["id"]);
string sqlText = "SELECT img_name, img_data, img_contenttype FROM

image1
where id="+liid;
SqlCommand MyCommand = new SqlCommand (sqlText, mycon);
SqlDataReader dr =MyCommand.ExecuteReader();
if(dr.Read())
{
Response.ContentType = (dr["img_contenttype"].ToString());
Response.BinaryWrite((byte[])dr["img_data"]);
}
mycon.Close();
}


Nov 18 '05 #4
Hello Kevin

How does it know to place the image in a specific IMG tag or a Image button?

yoramo

"Kevin Spencer" <ke***@takempis.com> wrote in message
news:u2****************@TK2MSFTNGP11.phx.gbl...
He already did. There is no Template HTML. It simply sends an image. You
include a reference to that page as the URL for an image tag in another
page.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Yoramo" <yoramo@[NOSPAM]hotmail.com> wrote in message
news:#8**************@TK2MSFTNGP10.phx.gbl...
hello

Thanks for your replay.
can you show me how whould the aspx file look like for such a code to work?

Yoramo.
"white sheng" <wh********@untsoft.com.cn> wrote in message
news:ec***************@tk2msftngp13.phx.gbl...
hi,you can do it just like the following example.

private void Page_Load(object sender, System.EventArgs e)
{
SqlConnection mycon = new SqlConnection("your connection string");
mycon.Open();

int liid = int.Parse(Request.QueryString["id"]);
string sqlText = "SELECT img_name, img_data, img_contenttype FROM

image1
where id="+liid;
SqlCommand MyCommand = new SqlCommand (sqlText, mycon);
SqlDataReader dr =MyCommand.ExecuteReader();
if(dr.Read())
{
Response.ContentType = (dr["img_contenttype"].ToString());
Response.BinaryWrite((byte[])dr["img_data"]);
}
mycon.Close();
}



Nov 18 '05 #5
<img src="ImageMaker.aspx">

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Yoramo" <yoramo@[NOSPAM]hotmail.com> wrote in message
news:et**************@TK2MSFTNGP12.phx.gbl...
Hello Kevin

How does it know to place the image in a specific IMG tag or a Image button?
yoramo

"Kevin Spencer" <ke***@takempis.com> wrote in message
news:u2****************@TK2MSFTNGP11.phx.gbl...
He already did. There is no Template HTML. It simply sends an image. You
include a reference to that page as the URL for an image tag in another
page.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Yoramo" <yoramo@[NOSPAM]hotmail.com> wrote in message
news:#8**************@TK2MSFTNGP10.phx.gbl...
hello

Thanks for your replay.
can you show me how whould the aspx file look like for such a code to work?

Yoramo.
"white sheng" <wh********@untsoft.com.cn> wrote in message
news:ec***************@tk2msftngp13.phx.gbl...
> hi,you can do it just like the following example.
>
> private void Page_Load(object sender, System.EventArgs e)
> {
> SqlConnection mycon = new SqlConnection("your connection string"); > mycon.Open();
>
> int liid = int.Parse(Request.QueryString["id"]);
> string sqlText = "SELECT img_name, img_data, img_contenttype FROM image1
> where id="+liid;
> SqlCommand MyCommand = new SqlCommand (sqlText, mycon);
> SqlDataReader dr =MyCommand.ExecuteReader();
> if(dr.Read())
> {
> Response.ContentType = (dr["img_contenttype"].ToString());
> Response.BinaryWrite((byte[])dr["img_data"]);
> }
> mycon.Close();
> }
>
>



Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Adam J Knight | last post by:
Hi all, Just wondering whats everyones prefered method of storing images ? 1) File System 2) Database (SqlServer) (Seems to be easier, but has a performance hit) Appreciate some insight!!!...
61
by: phil-news-nospam | last post by:
Why does SVG need a different tag than other images? IMHO, SVG should be implemented as an image type just like any other image type, allowing it to work with <img> tags, and ... here is the...
1
by: Xah Lee | last post by:
The following is a program to generate thumbnail images for a website. Useful, if you want to do that. It is used to generate the thumbnails for my “Banners, Damsels, and Mores” project...
11
by: vila | last post by:
Hi, I would like to display digits with a 7-bar display, as in a pocket calculator. Any ideas about how to do this? Francis
7
by: TechnoAtif | last post by:
Hi..There is again a similar problem..Now i;ve got the option values of list?menu box to show the textbox. If the option value of list is yes then the textbox is to be displayed . Can anyone...
1
by: cs_in_va | last post by:
I have been reading info on putting images inside vs out side the data and just using a path name. I want to use the later, but having some difficulties. Here is what I have. I have a database...
2
by: Tim Streater | last post by:
The following test page is intended to allow the user to choose an image file, and then display it. It works as expected in Safari 3.1.1, FF 2.0.0.14 (Mac), and IE7 (XP). But, it fails in FF...
6
by: rgagarrett | last post by:
Hi, I hope this is the correct group for my query, please advise if there's a more relevant place for me! I'm using a USB camera (Sentech C83) with Linux and I have some C code for reading data...
2
by: csihosting | last post by:
I would like to dispaly some images from a remote site (I have permission) on my asp.net page. The site required authentication. How do I retrieve the images and send the credentials without the user...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.