Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Cant store images in access table

Posted on 2004-08-20
3
Medium Priority
?
270 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 (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

618 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