?
Solved

Access OLE Object through ASP

Posted on 2003-02-21
6
Medium Priority
?
434 Views
Last Modified: 2007-12-19
I have created both the ASP page and the Access Database. The Access database has a field called picture with OLE Object as its Meta data. This field holds .jpg, .gif, or bitmap images. I can successfully connect to the database through the ASP page and run queries to the database. However when I ask it to return a picture from the database all I get is the word binary displayed as my result? The picture is in the database and I can view from the database. Has anyone tried this before and if so how did they do it? I have tried everything I can think of and nothing seems to work. Any help would be greatly appreciated.

Thanks.
0
Comment
Question by:rootdown_1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 20

Accepted Solution

by:
jitganguly earned 200 total points
ID: 7994325
Have your tried binarywrite ?

response.binarywrite rs("yourolecolumn")

Actually it is not a very good practice to store the image in a datbase for any web applications. You would rather put in a separate folder in your web server and point each of them with some id stored in database.

0
 

Author Comment

by:rootdown_1
ID: 7995421
Here is my code:
<%

sql = "select * from Name"
Set Conn = Server.CreateObject("ADODB.Connection")
Set RS   = Server.CreateObject("ADODB.RecordSet")
Conn.Open "Testpic"
RS.Open SQL, Conn
response.binarywrite rs("Picture")

%>


It only returns:

  $     ÿÿÿÿPackagePackage    PackageK  1.Õ ÿØÿà JFIF    , ,ÿÛC                  &#64979;     $.' ",#  (7),01444'9=82<.342ÿÛC     2! !

And so on. It looks like it is trying to read it. Do you have any more suggestions?
0
 
LVL 25

Expert Comment

by:clockwatcher
ID: 7996881
Storing your images as OLE objects and then trying to get them out will be a huge pain-- read that as next to impossible.

The problem is that when you use Insert OLE... the application registered to handle that file takes care of its actual binary storage format... so your jpegs may not be jpegs anymore.  The binary format that you end up storing isn't necessarily the same that you inserted-- depends upon the OLE server that's registered for that document.  For example, I have Corel PhotoPaint installed.  It takes of the OLE storage for my JPEGs and it doesn't necessarily keep them internally as a JPEG.  After using Insert Object, I've now got a Corel PhotoPaint "document" (OLE structured storage) in my Access database-- not a binary formatted jpeg.

Even if you're lucky enough to have your container application keep the binary format the same, you still have OLE header information tagged on to it.  So, you need to strip the OLE header information out.  There's an article with a BMP as an example on one of the ASP sites.  Can't remember exactly how many bytes you need to strip for a BMP (assuming your OLE Server is still PaintBrush for bitmaps... if it's not the amount of header may be different).  I can track down the article if you're really interested.

The trick to storing and using images from an Access database is to store them as BLOBs rather than OLE objects.  If you actually write the binary data directly into an OLE-type Access field (rather than using Insert Object), you end up with a BLOB rather than OLE structured storage.  Access will even tell you that.  It'll show up as in Access when you look at the field as BLOB.  You can binarywrite the BLOB and have it show up correctly.  If you want an example, let me know and I'll dig one up from a few years ago.

Most people will agree with jitganguly about it not being a good practice to store your images within the database, but rather store links to them.  I'm of the mind that it really depends upon the particular application and use whether it makes sense or not.  But, in general, they're right.  Just for performance purposes alone... IIS streams stuff from the file system a heck of lot faster than it'll spit out ASP streams.
0
 

Expert Comment

by:CleanupPing
ID: 9576966
rootdown_1:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 58

Expert Comment

by:Gary
ID: 9754396
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept Answer by jitganguly

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
GaryC123
EE Cleanup Volunteer
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question