J. Toop said:
The bandwidth between the dataset and the DB is usually of less concern
than the bandwidth between the dataset and the browser. They may be using
diaup or other slow connectivity methods.
OK.
Anyway the image must arrive to the browser, isn't it ?
How can the browser know what the bits are if it does not recieve MIME
information with the image. I thought that the browser had to know what
the bits were in order to interpret them for the user on the other end of
the browser.
OK, good point.
I thought the imagefield was so smart to look at the header of the image
stream (binary in the DB) to understend what kind of images it was.
This allows browsers to do stuff like, retrieve the text and slowly fill
in the images asynchronously and if the user decides to browse away in the
interim (before all of the images arrive) then that is his/her choice. The
server doesn't have to send the browser the files not requested. This
would save bandwidth.
OK, good point.
The gridview is html/text (or something like that) so if you send the
image as part of that stream you could get some really cool bytes on the
screen but you are thinking that the browser knows that these bytes were a
"png" or a "jpg" or a "gif" or a "bmp" (or some other?). file that you
uploaded into a field.
Yes, i hope so, but maybe i'm realizing it is not.
Whenever I've stored images in a database I've had to store the "mime
type" in a field and the size in bytes (so the browser knows I've sent it
all now ... stop making the Netscape Icon animate).
The size in byte could be known from the DB Field.
I worked with SQL Server and DB with Images.
I was able to know the size by the DB field they were stored,
and also i was able to show them feeding the leadtools control.
Remember that you can only retrive images from SQL server (I don't think
that MSAccess can do this)
I think yes, i have a sample it does.
------------------------------------------------
string idx;
idx = Request.QueryString["idx"];
if (idx == null)
idx = "1";
OleDbConnection myConn = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" +
Server.MapPath("App_Data\\Photos.mdb"));
myConn.Open();
OleDbCommand _OleCmd = new OleDbCommand("SELECT * FROM Tabella1 WHERE ID = "
+ idx, myConn);
OleDbDataReader dr = _OleCmd.ExecuteReader();
if (dr.Read())
{
Response.Clear();
Response.ClearContent();
Response.ContentType = dr["ContentType"].ToString();
Response.BinaryWrite((byte[])dr["Photo"]);
}
else
Response.Write("NOT FOUND!");
if (myConn.State != System.Data.ConnectionState.Closed)
myConn.Close();
------------------------------------------------
The access db has stored also the content type.
What about serving up "filename.doc" files. Then it all comes as one
stream and you don't have to worry about the complexities of writing an
"url" into an <IMG> tag or other active content issues.
How can i get a .doc file form an image stored in a DB ?
I can try for learning purpose, but i don't think this is usefull for my
monitoring application.
Thank you.
Auto.