BLOB in asp

K

Kevin Spencer

Since a BLOB is simply binary data (a stream of 1s and 0s), you cannot
display int in an ASP.Net or ASP page unless you know what the data is.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.
 
N

Nau

I forgot to mention that i have a 'gif ' image stored in the
database(oracle 9i) in a BLOB column , i need to display this data in a
asp page
 
K

Kevin Spencer

1. Create an ASP.Net page that will serve as an image. Use the
Request.QueryString to determine the file name. You can then add an image
tag to any page that points to its URL as it would point to an image file.
Example:

<img src="image.aspx?filename=foo.gif">

Read the data from the BLOB into a byte array. Set the Response.ContentType
of the page to "image/gif" Use Response.BiaryWrite to write the byte array
to the output stream.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Who is Mighty Abbott?
A twin turret scalawag.
 
D

Daniel Fisher\(lennybacon\)

Ya better write bit by bit

string _filePath = "..."

Response.Clear();
Response.ContentType = "image/gif";
Response.Buffer = false;
FileStream _fileStream = null;
byte[] _buffer = new byte[1024];
long _byteCount;
try
{
_fileStream = File.OpenRead(_filePath);
while ((_byteCount =
_fileStream.Read(_buffer, 0, _buffer.Length)) > 0)
{
if(Response.IsClientConnected)
{
Response.OutputStream.Write(
_buffer, 0, _buffer.Length);
Response.Flush();
}
else
{
return;
}
}
}
catch(Exception _ex)
{
throw _ex;
}
finally
{
_fileStream.Close();
}


--Daniel
http://staff.newtelligence.com/danielf/




-----Original Message-----
From: Kevin Spencer [mailto:[email protected]]
Posted At: Monday, January 23, 2006 1:01 PM
Posted To: microsoft.public.dotnet.framework.aspnet
Conversation: BLOB in asp
Subject: Re: BLOB in asp

1. Create an ASP.Net page that will serve as an image. Use the
Request.QueryString to determine the file name. You can then add an
image
tag to any page that points to its URL as it would point to an image
file.
Example:

<img src="image.aspx?filename=foo.gif">

Read the data from the BLOB into a byte array. Set the
Response.ContentType
of the page to "image/gif" Use Response.BiaryWrite to write the byte
array
to the output stream.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Who is Mighty Abbott?
A twin turret scalawag.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,522
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top