By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,948 Members | 1,929 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,948 IT Pros & Developers. It's quick & easy.

display images without having them on the disk?

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
<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 discussion thread is closed

Replies have been disabled for this discussion.