?
Solved

Cant store images in access table

Posted on 2004-08-20
3
Medium Priority
?
264 Views
Last Modified: 2011-10-03
In MS-Access 2000 i have a  table with a field image of data type OLE Object. Now when i try to add some value (Picture) in this field by :
While entring data right click on this filed -->opens a small floating window --> select Insert  Object --> it opens a Insert Object Dialog Box with two radio buttons (Create new and Create from file). --> select Create From file and the click at browse button and after selecting  the directory and file (.bmp or .jpg) from Browse box. now when i press ok in the "Insert Obect" dialog box it displays "Package" in the image field in the table.
Whereas i think it should display "Bitmap Image" here. Am i Right ? and if yes, then What is the problem.
0
Comment
Question by:astudent
[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
  • 3
3 Comments
 
LVL 7

Expert Comment

by:Enlade
ID: 11851174

Yes, you store them as a Blob (or really vbLongBinary).  So create a DB field like this:

  Set Fld(2) = NewTBL.CreateField("Pic", dbLongBinary)

Then you save the data into the field like this:

  tempRcSet("Pic").AppendChunk Pic

And you can get the data from the field like this:

  ReDim Pic(0 To (nBytesPic - 1)) As Byte
  Pic = tempRcSet("Pic").GetChunk(0, nBytesPic)

Note that you will need to change the field number and to change fill Pic and nBytesPic appropriately.  You will also need to store nBytesPic in the DB as well (its just easier).  Then you can use that to tell you if a picture is stored or empty (if it is 0 or > 0).

Your next question is how you get the picture into the byte array.  Let me get that for you....
0
 
LVL 7

Expert Comment

by:Enlade
ID: 11851209

Yea, that is the problem.  How do you get the picture into the byte array.  I use a control that I purchased that allows me to save a picture into a byte array, but you probably don't have that control.  If I remember correctly I bought that control specificly to do this because I think I read that most people suggested saveing the JPG to a temporary file and then loading the file into a byte array before you save it into the database (as discribed above).  Let me see if I can confirm that for you.

Mind you if you want to do it the simple way and you don't mind buying a control you could get this one:

http://www.phototrue.net/

Its not a bad price.  Still, let me see if I can find out how to get the picture into a byte array.


0
 
LVL 7

Accepted Solution

by:
Enlade earned 150 total points
ID: 11851224

Yea, Microsoft suggests that you write a function to save and load Blobs to files and then when you load them you load them back into a byte array that you can GetChunk and PutChunk to the dbLongBinary field in your DB.  I can give you the link to Microsoft, but here is a link on EE that gives you more detail.

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/VB_Databases/Q_10208746.html?query=Saving+Pictures+into+Access&clearTAFilter=true

Now, I hated that solution.  So, I just went out and bought PhotoTrue and it not only gave me some minor graphic manipulation functions, it also allowed me to print an image directly into a byte array (thus avoiding that whole file processing mumbo jumbo).
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month10 days, 17 hours left to enroll

770 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