PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 1.00 average.

Display Pictures from Access database

 
 
CJ
Guest
Posts: n/a
 
      20th Jan 2004
I have an access database located in the fpdb subfolder of my web site. One
of the fields contains an image - this image is actually stored within the
Access database, rather than being a file stored outside the database.

I want my Database Results wizard to show this picture automatically, but
all I get is << BINARY >> instead of the picture.

I found lots of help on the web about displaying pictures located outwith
the database, but this isn't what I want.

The page is located at http://www.mymea.co.uk/fred/searcha.asp

Many thanks.

CJ


 
Reply With Quote
 
 
 
 
CJ
Guest
Posts: n/a
 
      21st Jan 2004
> I found lots of help on the web about displaying pictures located outwith
> the database, but this isn't what I want.
>
> The page is located at http://www.mymea.co.uk/fred/searcha.asp
>
> Many thanks.
>


Please ignore, I found the answer:

When working with an Access OLE Object field, you are working with binary
data. Therefore you can't use the typical "Response.Write..." to display an
image stored in the database. It's really rather tricky to do, as the
database also stores a header in the field which indicates what type of
object is stored in it. In order to even work with the data, you have to
first strip out the header. The only way to do this at this point is to
build a custom COM object that strips out the header and returns a binary
stream. The problem with this (aside from having to write a custom COM
object) is getting your hosting service to register the COM object on their
server. Hosting services are not particularly fond of registering 3rd-party
COM objects on their servers.

The best thing to do if you can, is to store the images in a file on your
web, ad store the paths to the images in your database. Then you can use the
path from the database to dynamically build an image source tag.

CJ


 
Reply With Quote
 
xmas
Guest
Posts: n/a
 
      21st Jan 2004
Hi CJ,

It really is easier than all that...

http://office.microsoft.com/assistan...EC010553071033

The images are put in the images folder and the database retrieves them
and inserts them in the page..

If you have acrobat Reader you might find this links page of interest.
(a zipped PDF File)

www.xmas-i-am.com/flash/fplinks.zip

xmas
=============================
"CJ" <(E-Mail Removed)> wrote in message
news:H_CdnXMhPNtgXJDdRVn-(E-Mail Removed)...
| > I found lots of help on the web about displaying pictures located
outwith
| > the database, but this isn't what I want.
| >
| > The page is located at http://www.mymea.co.uk/fred/searcha.asp
| >
| > Many thanks.
| >
|
| Please ignore, I found the answer:
|
| When working with an Access OLE Object field, you are working with binary
| data. Therefore you can't use the typical "Response.Write..." to display
an
| image stored in the database. It's really rather tricky to do, as the
| database also stores a header in the field which indicates what type of
| object is stored in it. In order to even work with the data, you have to
| first strip out the header. The only way to do this at this point is to
| build a custom COM object that strips out the header and returns a binary
| stream. The problem with this (aside from having to write a custom COM
| object) is getting your hosting service to register the COM object on
their
| server. Hosting services are not particularly fond of registering
3rd-party
| COM objects on their servers.
|
| The best thing to do if you can, is to store the images in a file on your
| web, ad store the paths to the images in your database. Then you can use
the
| path from the database to dynamically build an image source tag.
|
| CJ
|
|


 
Reply With Quote
 
CJ
Guest
Posts: n/a
 
      21st Jan 2004
> The images are put in the images folder and the database retrieves them
> and inserts them in the page..


Thanks, that's what I'd concluded - the images are stored outside the
database rather than as an OLE object inside it. The database instead
contains just the filename of the image as a text field, and the web page
drags the image from the images folder when the results wizard runs.

That's not ideal for my purposes, because the images have to be part of the
database for another reason, and it just seemed logical to use them from
there rather than create them again on the web server.

Thanks again.

CJ


 
Reply With Quote
 
chris leeds
Guest
Posts: n/a
 
      21st Jan 2004
while it's not the db wizard, I have a script in php that pulls images from
an mysql database and writes them onto the page. i could copy the page that
does this for you.

"CJ" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> > The images are put in the images folder and the database retrieves them
> > and inserts them in the page..

>
> Thanks, that's what I'd concluded - the images are stored outside the
> database rather than as an OLE object inside it. The database instead
> contains just the filename of the image as a text field, and the web page
> drags the image from the images folder when the results wizard runs.
>
> That's not ideal for my purposes, because the images have to be part of

the
> database for another reason, and it just seemed logical to use them from
> there rather than create them again on the web server.
>
> Thanks again.
>
> CJ
>
>



 
Reply With Quote
 
CJ
Guest
Posts: n/a
 
      21st Jan 2004

> while it's not the db wizard, I have a script in php that pulls images

from
> an mysql database and writes them onto the page. i could copy the page

that
> does this for you.


Thanks, but the databse I have is already in Access.

CJ


 
Reply With Quote
 
=?Utf-8?B?SmFtbWVu?=
Guest
Posts: n/a
 
      12th Mar 2004
hey, i was buzzing the newsgroups and i can give you the code for it
its no worries, i store images in an access dbase as well using ole objec
and pull it out displaying it on the page just fine. I'm using VBScript to do it, so
i don't know about your environment, but this should help you get on the right track

Use the getimage.asp to pull the images from showimage.as
You're passing a query to the showimage.asp file which renders the image from th
Access Dbase and displays it on the getimage.asp page using the Primary Ke
from the Imagetable in the dbase you're using

I hope this helps. If you can help me figure out how to replace the OLE Object imag
from the field that would be great. i'm having issues w/ that, it doesn't want to overwrit
the image, yet it won't throw me any errors to start figuring out how to do it

incidently, if a person tries to save the image, it will save as 'showimage.asp' and open i
a text editor in binary. they'd have to know to rename it to the proper file extension of the
image itself.

I've tested this w/ png,jpg,gif and it works fine for my purposes.

cheers

James Mendha
Brave Pixel Media Cor
Vancouver, BC
(E-Mail Removed)

<text listed below:

getimage.asp

<
'declare some job
Dim Conn, objRS, SQ
SQL = "SELECT * FROM <TableName> order by id desc
Set Conn = Server.CreateObject("ADODB.Connection"
'ms access dsnless connectio
dim db_connec
db_connect="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=<driveletter>:/<path-to-database>/<ImageDatabase>.mdb
Conn.Open db_connec
Set objRS = Server.CreateObject("ADODB.Recordset"
objRS.Open SQL, Con
%><html><HEAD><TITLE>showphoto</TITLE></HEAD><body bgcolor="#ffffff"><table cellpadding="2" cellspacing="2" border="0" width="90%"><tbody><% do while not RS.EOF %><tr valign="Top"><td valign="Top"><img src="showimage.asp?ID=<%= objRS("ID")%>" width="<%objRS("ImageWidth")%>" border="0"></td></tr><%
RS.MoveNex
Loop
%></table></body></html><
'Clean up..
objRS.Clos
Set objRS = Nothin
Conn.Clos
Set Conn = Nothin
%

showimage.as

<
dim db_connec
db_connect="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:/webserver/databases/PhaseMechanic.mdb
%><
REM Step 1: Read in ID from querystring in file get.as
Dim I
ID = Request.QueryString("ID"

REM Step 2: select picture from ms acces
Dim Conn, RS, SQ
SQL = "SELECT <ImageField> FROM <tableName> WHERE ImagetID = " & I

REM step 3: make a dbase connectio
Set Conn = Server.CreateObject("ADODB.Connection"

Conn.Open db_connec
Set RS = Server.CreateObject("ADODB.Recordset"
RS.Open SQL, Con

REM Step 4: Set the ContentType to image/jp
Response.ContentType = "image/jpg

REM Step 5: Use Response.BinaryWrite to output the imag
Response.BinaryWrite RS("ImageData"

RS.Clos
Set RS = Nothin
Conn.Clos
Set Conn = Nothin
%>
 
Reply With Quote
 
Kevin Spencer
Guest
Posts: n/a
 
      12th Mar 2004
This code would only work if the images were not insereted into the database
using Access, but were inserted programmatically without headers, as it does
not account for the OLE Object headers that Access creates in the field.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Jammen" <(E-Mail Removed)> wrote in message
news:50470156-4DFE-43C8-8951-(E-Mail Removed)...
> hey, i was buzzing the newsgroups and i can give you the code for it.
> its no worries, i store images in an access dbase as well using ole object
> and pull it out displaying it on the page just fine. I'm using VBScript

to do it, so
> i don't know about your environment, but this should help you get on the

right track.
>
> Use the getimage.asp to pull the images from showimage.asp
> You're passing a query to the showimage.asp file which renders the image

from the
> Access Dbase and displays it on the getimage.asp page using the Primary

Key
> from the Imagetable in the dbase you're using.
>
> I hope this helps. If you can help me figure out how to replace the OLE

Object image
> from the field that would be great. i'm having issues w/ that, it doesn't

want to overwrite
> the image, yet it won't throw me any errors to start figuring out how to

do it.
>
> incidently, if a person tries to save the image, it will save as

'showimage.asp' and open in
> a text editor in binary. they'd have to know to rename it to the proper

file extension of the
> image itself.
>
> I've tested this w/ png,jpg,gif and it works fine for my purposes.
>
> cheers,
>
> James Mendham
> Brave Pixel Media Corp
> Vancouver, BC.
> (E-Mail Removed)
>
> <text listed below:>
>
> getimage.asp
>
> <%
> 'declare some jobs
> Dim Conn, objRS, SQL
> SQL = "SELECT * FROM <TableName> order by id desc"
> Set Conn = Server.CreateObject("ADODB.Connection")
> 'ms access dsnless connection
> dim db_connect
> db_connect="Provider=Microsoft.Jet.OLEDB.4.0;Data

Source=<driveletter>:/<path-to-database>/<ImageDatabase>.mdb"
> Conn.Open db_connect
> Set objRS = Server.CreateObject("ADODB.Recordset")
> objRS.Open SQL, Conn
> %><html><HEAD><TITLE>showphoto</TITLE></HEAD><body

bgcolor="#ffffff"><table cellpadding="2" cellspacing="2" border="0"
width="90%"><tbody><% do while not RS.EOF %><tr valign="Top"><td
valign="Top"><img src="showimage.asp?ID=<%= objRS("ID")%>"
width="<%objRS("ImageWidth")%>" border="0"></td></tr><%
> RS.MoveNext
> Loop
> %></table></body></html><%
> 'Clean up...
> objRS.Close
> Set objRS = Nothing
> Conn.Close
> Set Conn = Nothing
> %>
>
> showimage.asp
>
> <%
> dim db_connect
> db_connect="Provider=Microsoft.Jet.OLEDB.4.0;Data

Source=d:/webserver/databases/PhaseMechanic.mdb"
> %><%
> REM Step 1: Read in ID from querystring in file get.asp
> Dim ID
> ID = Request.QueryString("ID")
>
> REM Step 2: select picture from ms access
> Dim Conn, RS, SQL
> SQL = "SELECT <ImageField> FROM <tableName> WHERE ImagetID = " & ID
>
> REM step 3: make a dbase connection
> Set Conn = Server.CreateObject("ADODB.Connection")
>
> Conn.Open db_connect
> Set RS = Server.CreateObject("ADODB.Recordset")
> RS.Open SQL, Conn
>
> REM Step 4: Set the ContentType to image/jpg
> Response.ContentType = "image/jpg"
>
> REM Step 5: Use Response.BinaryWrite to output the image
> Response.BinaryWrite RS("ImageData")
>
> RS.Close
> Set RS = Nothing
> Conn.Close
> Set Conn = Nothing
> %>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pictures in Access Database beadingbetsy Microsoft Access Reports 1 11th Sep 2009 03:10 AM
Pictures in Access Database Fred's Microsoft Access 3 9th Dec 2008 11:56 PM
How to display multiple pictures per record in an Access database? Wadim Grasza Microsoft Access 3 7th Sep 2005 01:17 AM
how to display multiple pictures per record in an access database =?Utf-8?B?V2FkaW0gR3Jhc3ph?= Microsoft Access Forms 3 6th Sep 2005 12:17 PM
pictures in access database =?Utf-8?B?ZG91ZyBT?= Microsoft Access 1 22nd Apr 2005 09:58 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:45 PM.