•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP section within the Web Development category of DaniWeb, a massive community of 427,795 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,687 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP advertiser: Lunarpages ASP Web Hosting
Views: 6036 | Replies: 4
•
•
Join Date: Oct 2006
Posts: 5
Reputation:
Rep Power: 0
Solved Threads: 0
All i wanna do is simple, I wanna display an image from an access database.
I try alot of things to no result. Like ascii code or nothing but a blank image with a red 'X'.
Here is the code :
I also tried a file named ShowPicture.asp and call it from another file like this:
I also try this :
All i got is tons ascii codes.
Can you help me on this ?
thanx
Chris
I try alot of things to no result. Like ascii code or nothing but a blank image with a red 'X'.
Here is the code :
<%
set conn=server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.jet.oledb.4.0"
conn.Open(server.MapPath("test1.mdb"))
set rs= conn.Execute("SELECT photo FROM photos where ID=1")
Response.ContentType="image/jpg"
Response.BinaryWrite(rs("photo"))
conn.Close
%>I also tried a file named ShowPicture.asp and call it from another file like this:
<IMG SRC="ShowPicture.asp?PhotoId=1">
ShowPicture.asp
<%
'Declare Variables
Dim sql
Dim rs
Dim conn
Dim userID,str
userID = Request("PhotoId")
If userID = "" Then userID = 0
'Instantiate Objects
Set conn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")
'Open connection
conn.Provider="Microsoft.jet.oledb.4.0"
conn.Open(server.MapPath("test1.mdb"))
'Get the specific image based on the ID passed in a querystring
str = "SELECT photo FROM photos where ID =" & userID
rs.Open str, conn,3,3
if rs.eof then 'No records found
Response.End
else 'Display the contents
Response.ContentType = "image/jpg"
Response.BinaryWrite(rs("photo"))
end if
'destroy the variables.
rs.Close
conn.Close
set rs = Nothing
set conn = Nothing
%>I also try this :
<body>
<%
set conn=server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.jet.oledb.4.0"
conn.Open(server.MapPath("test1.mdb"))
set rs= conn.Execute("SELECT photo FROM photos where ID=1")
Response.ContentType="image/jpg"
%>
<img src="<%Response.BinaryWrite(rs("photo"))%>">
<% conn.Close %>
</body>
Can you help me on this ?
thanx
Chris
•
•
•
•
•
•
•
•
DaniWeb ASP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- how to display one image per day from an array? (JSP)
- display image when button clicked (Java)
- retrieving image from mysql database using php (PHP)
- Display image for background (Java)
- what is wrong with yhis code? (PHP)
Other Threads in the ASP Forum
- Previous Thread: Hi friends... plz help me
- Next Thread: HTTP Error 403 - Forbidden error for accessing html and asp page



Threaded Mode