473,614 Members | 2,101 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem with retrieve image from database

6 New Member
<img src="image.asp? id=1">

---------------------------------------------------------------
<%Option Explicit%>
<!-- #include file="IMS/includes/dbconn.asp"-->

<%

dim MyConn,SQL
Set MyConn = Server.CreateOb ject("ADODB.Con nection")
MyConn.Open dbConn
SQL = "SELECT pic,name,size FROM img where id="& Request.QuerySt ring("id")
Set rs =MyConn.Execute ( SQL )
while not rs.eof then
response.Conten tType="image/jpeg"
Response.AddHea der "Content-Disposition", "attachment;fil ename=" & Trim(rs("name") )
Response.AddHea der "Content-Length", rs("size")
Response.Binary Write rs("pic")
rs.MoveNext
wend

rs.close
set rs=nothing

%>
----------------------------------------------------------
I managed to insert image into MySQL database but i can't retrieve. Any ASP expert can help me? . Thanks
Feb 24 '08 #1
3 1894
jagged
23 New Member
What error are you getting?

Personally I've never used the Response.AddHea der "Content-Disposition", "attachment;fil ename=" & Trim(rs("name") )
Response.AddHea der "Content-Length", rs("size") when outputting images so you can try to comment them out and see if that helps.

I would also remove the loop. Im not sure outputting two images one after the other would work, so just check if rst.eof = true.
Feb 24 '08 #2
CroCrew
564 Recognized Expert Contributor
Hello alexseow,

Here is an example using an Oracle server http://www.narfle.com/ref/asp/oracleBlob.asp that might help you out.

Hope you find your answer~
Feb 25 '08 #3
Karthikkommandi
1 New Member
Hi

I am also getting similar type of problem.
for retriving imgaes i am also using similar code. But i am getting Grabage values in web browser. It seems that it is displaying all binary data. like this...
[
ÿØÿàJFIF``ÿ í Photoshop 3.08BIMí Resolution`` 8BIM FX Global Lighting Anglex8BIMF X Global Altitude8BIM ó Print Flags 8BIM Copyright Flag8BIM'..... ........
]

can anybody help me regarding this issue. as i am new to asp i am not able to fix this issue. Thanks in advance
Apr 2 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
3305
by: Iain Bishop | last post by:
I'm trying to model objects for the following problem: A building site contains assemblies, each of which can contain other assemblies and/or materials. I have modelled this using a Site class, Assembly class, and Material class as follows... Site Class (clsSite): Option Explicit
0
1242
by: Lata Neti | last post by:
I am trying to retrieve images from SQL server and display them on the client’s browser. Images in the SQL server are imported from MS Access 2002 I found the following code that mentions about removing the OLE Header for Northwind Database. I tried using the same logic to retrieve images from the database that I imported and got an error “Invalid parameter” when trying to run the program
2
5420
by: Rob | last post by:
Hi all, I've got multiple sets of radio button that are dynamically created in code and populated by a database query. The query returns about 20 recordsets with 3 radio buttons per recordset and I want to be able to retrieve the selected value from each of the sets of radio buttons.The names of each group of radio buttons is set by the database and I don't know how to retrieve the values because I don't know the names of these radio...
2
2579
by: Jeronimo Bertran | last post by:
Hello, I am using a rendering aspx page to display a database image on an Image control. When the database record is retrieved, I am saving the bitmap to a session variable for the rendering aspx to load. Here is the code on the rendering page: CODE FOR ImageForm.aspx private void Page_Load(object sender, System.EventArgs e)
2
3742
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. At least when I execute the following code, I get some significant network traffic. When I check the database with query analyzer, I see 4 Hex Chars in the image colum. Like 0xe0 etc.
0
1485
by: Tony Lugg | last post by:
I have an application with a document management form. When users add documents to the form, I call the API function SHGetFileInfo to get the associated large and small icons for the file. These icons are added to two ImageList objects which are bound to a ListView control, and everything looks great. I am saving the icons to a SQL Server table by using Icon.Save to a stream and assigning the byte array to the field, then loading them...
3
2751
by: Tony Lugg | last post by:
I have an application with a document management form. When users add documents to the form, I call the API function SHGetFileInfo to get the associated large and small icons for the file. These icons are added to two ImageList objects which are bound to a ListView control, and everything looks great. I am saving the icons to a SQL Server table by using Icon.Save to a stream and assigning the byte array to the field, then loading them...
9
8155
by: philip | last post by:
If I execute that : Dim Temp as string = "This is a text" Dim sw As StreamWriter Dim fullFileName as string = "c:\text.txt" sw = New StreamWriter(fullFilename) sw.Write(temp) sw.Close() the resulting file 'Text.txt' has the same length than the string 'temp'.
1
1340
by: T00ks | last post by:
The Background: I have data stored in an SQL Database, i'm using asp.net and c# to retrieve the data from the database and update the client side asyncronously (sp?). the behind code looks as follows: The Code: private void loadNews(int? newsID) {
0
8620
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
8571
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
8423
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
7047
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6085
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5537
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
4115
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1705
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1420
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.