473,287 Members | 1,570 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Reading BLOB field into Image Web Control - Not working properly

I have some problems with the way I am showing the BLOB fields in the
Image web controls. It does work on my localhost though sometimes I
need to hit Refresh for the images to load properly. However, when I
try to access the same page from another machine or when I test the
code on a remote server the images just wouldn't show.

The page I am talking about has 3 Image web controls. In the
CodeBehind I am loading these controls by using an auxiliary aspx
page. The Code looks like this:

Main Page
=========

..
..
protected System.Web.UI.HtmlControls.HtmlInputFile banner1;
protected System.Web.UI.HtmlControls.HtmlInputFile banner2;
protected System.Web.UI.HtmlControls.HtmlInputFile banner3;
..
..
loadImage(ref imgMainBanner, "banner1");
loadImage(ref imgMainBanner, "banner2");
loadImage(ref imgMainBanner, "banner3");
..
..
private void loadImage(ref System.Web.UI.WebControls.Image imgControl,
string imageName)
{
imgURL = "GetImage.aspx?imageName=" + imageName;
imgControl.ImageUrl = imgURL;
}

GetImage.aspx
=============

string imageName = Request["imageName"];
byte[] b = businessRules.getImage(imageName);

if (b != null)
{
Response.Clear();
Response.ContentType = "image";
Response.BinaryWrite(b);
Response.Flush();
Response.Close();
}

Now here are my questions if you could kindly help me out with this:

1) Is there any other way to do this without writing the binary
contents of the BLOB into a physical file? I fear the administrators
wouldn't like the idea of end users writing files on the server any
time they hit this page.

2) Why would this solution work on my localhost (sometimes with the
help of the Refresh button) but not on remote servers?

3) Is it possible to create a file in memory and link it to the Image
web control? If so, how?

I would greatly appreciate your help on this issue. And be even more
thankful if you include some sample code.

Thanks!
Jose R. Castro
Nov 16 '05 #1
1 3279
Just to share the solution with you: While looking at one Classic ASP
page I saw that the auxiliary page used Response.End() instead of
Response.Close(). That made a big difference and the page is working
properly now.

Jose R. Castro

jr********@yahoo.com (Roberto Castro) wrote in message news:<4e**************************@posting.google. com>...
I have some problems with the way I am showing the BLOB fields in the
Image web controls. It does work on my localhost though sometimes I
need to hit Refresh for the images to load properly. However, when I
try to access the same page from another machine or when I test the
code on a remote server the images just wouldn't show.

The page I am talking about has 3 Image web controls. In the
CodeBehind I am loading these controls by using an auxiliary aspx
page. The Code looks like this:

Main Page
=========

.
.
protected System.Web.UI.HtmlControls.HtmlInputFile banner1;
protected System.Web.UI.HtmlControls.HtmlInputFile banner2;
protected System.Web.UI.HtmlControls.HtmlInputFile banner3;
.
.
loadImage(ref imgMainBanner, "banner1");
loadImage(ref imgMainBanner, "banner2");
loadImage(ref imgMainBanner, "banner3");
.
.
private void loadImage(ref System.Web.UI.WebControls.Image imgControl,
string imageName)
{
imgURL = "GetImage.aspx?imageName=" + imageName;
imgControl.ImageUrl = imgURL;
}

GetImage.aspx
=============

string imageName = Request["imageName"];
byte[] b = businessRules.getImage(imageName);

if (b != null)
{
Response.Clear();
Response.ContentType = "image";
Response.BinaryWrite(b);
Response.Flush();
Response.Close();
}

Now here are my questions if you could kindly help me out with this:

1) Is there any other way to do this without writing the binary
contents of the BLOB into a physical file? I fear the administrators
wouldn't like the idea of end users writing files on the server any
time they hit this page.

2) Why would this solution work on my localhost (sometimes with the
help of the Refresh button) but not on remote servers?

3) Is it possible to create a file in memory and link it to the Image
web control? If so, how?

I would greatly appreciate your help on this issue. And be even more
thankful if you include some sample code.

Thanks!
Jose R. Castro

Nov 16 '05 #2

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

Similar topics

7
by: John | last post by:
I have over 5000 thumbnail pictures of size 5kb each. I would like to able to load all 5000 pictures and view 50 per page using mysql_data_seek(). I would like to know what are the advantages and...
4
by: mir nazim | last post by:
hi, i m facing a problem in properly accesing BLOBs from mysql db. when i display an image stored in the blob field it show some absurd characters. i think it is the problem of properly telling...
3
by: NotGiven | last post by:
I am researching the best place to put pictures. I have heard form both sides and I'd like to know why one is better than the other. Many thanks!
1
by: red | last post by:
I'm probably crazy for even trying this but I'm trying to make a script that will iterate through my databases, iterate through all the tables, and show everything on one page in forms that allow...
6
by: Pierre-Benoit | last post by:
Hi there, I've a strange problem with ado.net and an Access db. I need to create a little C# app that take the content of "ole object" field and then save it into a file. The problem is that...
1
by: sid_mulpuru | last post by:
I am trying to read data from a DB2 Blob Data type Field (using wsad 5.1.0) using getBlob() which when executed gives an SQL Exception 2005-01-07 15:48:40,506 ERROR - Error in...
2
by: Chucker | last post by:
Hi Community, I think I can store Binary Data in SQL Server but when I try to retrieve it, I always only get one byte. I think I stored my Binary Data in SQL Server in a Colum of Type Image....
1
by: yoes | last post by:
Dear all, I am very new in MySQL, I am working on image database project for my research and I have problem how to convert blob field into float in MySQL so that I can calculate the blob field...
55
ADezii
by: ADezii | last post by:
Of all the questions asked here at TheScripts, the one which appears with the most frequency relates to the storing of Graphic Images within Access. There are basically three techniques available to...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.