473,788 Members | 2,895 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Retrieving image from SQL (C#) problem

This is kind of silly, but I just cannot figure out why:

In ASP.NET 2.0 I am retrieving images from a MS SQL server, and writing them
as binary to a separate page as the url for image controls, everything by
the book. I have been doing this a lot with VB. Now I am writing a new
application in C#, and the strange thng is this:

- it works well in debug mode
- but not on the published folder on the same server (localhost) - image
frames all have a cross in them
- a VB coded Image.aspx works well also on the published folder

Her is the C# code in the Image.aspx file::

.....som init code...

SqlConnection con = new SqlConnection(i nit.con());
con.Open();
string strSQL = "SELECT img FROM photo where ID= " + ID;
SqlCommand cmd = new SqlCommand(strS QL, con);
imagebyte = (byte[])cmd.ExecuteSca lar();
con.Close();
Response.Clear( );
Response.Conten tType = "image/jpeg";
Response.Binary Write(imagebyte );
Response.Buffer Output= true;

--Why does this work in debug mode, and not on the published folder?

Bjorn
Nov 13 '07 #1
2 3941
If you set Response.Buffer Output= true; you will likely need to call
Response.Flush( ); at some stage.

If the page is just serving images, there should not be any reason for
setting Response.Buffer Output= true.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Bjorn Sagbakken" <bj*****@online .nowrote in message
news:3_******** *************@t elenor.com...
This is kind of silly, but I just cannot figure out why:

In ASP.NET 2.0 I am retrieving images from a MS SQL server, and writing
them as binary to a separate page as the url for image controls,
everything by the book. I have been doing this a lot with VB. Now I am
writing a new application in C#, and the strange thng is this:

- it works well in debug mode
- but not on the published folder on the same server (localhost) - image
frames all have a cross in them
- a VB coded Image.aspx works well also on the published folder

Her is the C# code in the Image.aspx file::

....som init code...

SqlConnection con = new SqlConnection(i nit.con());
con.Open();
string strSQL = "SELECT img FROM photo where ID= " + ID;
SqlCommand cmd = new SqlCommand(strS QL, con);
imagebyte = (byte[])cmd.ExecuteSca lar();
con.Close();
Response.Clear( );
Response.Conten tType = "image/jpeg";
Response.Binary Write(imagebyte );
Response.Buffer Output= true;

--Why does this work in debug mode, and not on the published folder?

Bjorn

Nov 13 '07 #2
"Eliyahu Goldin" <RE************ **************@ mMvVpPsS.orgwro te in
message news:O1******** ******@TK2MSFTN GP03.phx.gbl...
If you set Response.Buffer Output= true; you will likely need to call
Response.Flush( ); at some stage.

If the page is just serving images, there should not be any reason for
setting Response.Buffer Output= true.
Well, I removed the Response.Buffer Output=true

and still the result is the same: in debug mode this works, but not when
running on the published folder.

Bjorn
Nov 13 '07 #3

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

Similar topics

5
1802
by: Jim Buzbee | last post by:
I have a subroutine that inserts image objects into a page for me. It works fine except for one thing. My mouseover settings don't appear to take. i.e. I see nothing at all when I move the mouse cursor over the image. If I replace the object creation code with a plain document.write, it works. : // this works as expected document.write("<img src='marker12.gif' \ id='1' \
4
1278
by: Angel | last post by:
Is there anyway that I can obtain information about an image file such as a ..jpg before I display it onto a screen. In other words, I would like to obtain the image size so I can dynamically place it on the screen. I like to set the width and height values according to what the size of the image is. I do not know whtat the size is at the time, because I will pick up the image file to what the user wants displayed. I want to display that...
9
3414
by: Andy Baxter | last post by:
hello, I'm writing a panoramic image viewer in html / javascript. The idea is I have a div with two identical panoramic photographs embedded in it. The clipping on the div is set to make it a viewport onto the images. Then I use javascript to make the two images scroll through the viewport - the second image is just there to fill the gaps when the first scrolls off the screen. They are seamless 360 degree panoramas, so this gives the...
0
935
by: Erik Lautier | last post by:
Hello, I'm using a multipart/form-data upload to put an image into SQL Server, and it appears to be working (though the Image field in my table still says "binary"). The upload code is: Dim intImageSize As Int64 Dim strImageType As String Dim ImageStream As Stream intImageSize = Picture.PostedFile.ContentLength strImageType = Picture.PostedFile.ContentType
0
1854
by: velmani | last post by:
hi , i have problem with Retrieving image from DB i have a table with image datatype i store a file by using code as follows -------------------------------------------------- string strType; int intLength,intStatus; Stream ipStream; intLength = File1.PostedFile.ContentLength; strType = File1.PostedFile.ContentType;
2
2252
by: shivapadma | last post by:
i have inserted the image into database using the following code String driverName = "com.mysql.jdbc.Driver"; String url = "jdbc:mysql://localhost:3306/"; String dbName = "hibernatetutorial"; String userName = "root"; String password = "root";
0
1254
by: MATTXtwo | last post by:
guys I have this problem related to image editor.. I 'm developing a project that can resize,add text,move rectangle for crop an image also scroll for bigger image.. the problem is I don't know how to make it display perfectly this is the code that i've use for all function above graphic=image.CreateGraphic graphic.DrawImage(sourceImage,rectangle,x,y,width,height,graphicunitpixel) but when ever it switch between all...
1
1848
by: jeremi achigbue | last post by:
i am using TOAD,i need help in storing and retrieving image from oracle9i database. here is my code: Imports System.Data.OracleClient Imports System.Data Imports System .Drawing Imports System.IO Imports System.Web Imports System.Configuration Imports System.Drawing.Imaging
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10366
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10173
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9967
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5399
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4070
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3674
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.