Storing files in Access

  • Thread starter Thread starter victorb17
  • Start date Start date
V

victorb17

Guest
Is it possible to store files in an Access Database. Like in an Oracle database. I want to store .rtf and other types, but can't find any info on the subject. Thanks!
 
If you look at the data types in the design view of a table, you'll see that one of the types is called "OLE Object". You can embed or link a document into there.

Look into this and see if it helps you.

SHADOW
 
Great I figured it out! I'm now trying to write an SQL statment to insert it from a win32 GUI program I am writing in C/C++. Here is what I have:
INSERT INTO [FORMS](FORM) VALUES(C:\\Victor\'s Stuff\\Programming\\NEW\\Notes\\book.BMP)
This doesn't work. Could you show me how to write one that can insert the file? Thanks!
 
You do not normally insert files into Access forms.. rather into tables.

Something like:

INSERT INTO
tblValuesNew ( [Value] )

SELECT
tblValues.Value

FROM
tblValues;

HTH :)
 
You can do this by storing the records of the file as memo fields, then putting some file discriminator (i.e. a key that says which file it belongs to) and a position discriminator (i.e. line number).

You would need a table to hold file names. Another table holds your records.

In VBA, define the file name by writing it to a recordset with a unique key. Do the .Update and then copy out the key.

Now you would open the file for input. Read the input line. Start counting line numbers. Store the file key and line number key along with your memo field that is your actual file record.

OK, now that I've answered your question, the question of whether this is a practical thing is separate. If you are doing it to learn or play around, well and good. If you were hoping to hide something from someone as an added layer of security, that might be OK if you did encryption along the way, maybe...

BUT if this is supposed to be productive, you need to be aware that you are adding a layer of obfuscation that will eventually frustrate you in trying to get something out. Fer instance, if you are storing a file in C++ language, you cannot compile it while it is in Access .mdb files. C++ wants a separate file. The essentially free-form data that is a source program rarely is consistent with any sort of decent data storage algorithm that one might use with Access.

AND - there is an easy path to something called 'database bloat' by using such methods as OLE encoding. Many people use OLE with the "embedded" option, but this way leads to databases best described as "beached whales." They won't compress much if at all, they are susceptible to problems if you ever upgrade the program being linked, and as they grow, they tend to require more and more of your system's resources.

To be specific about the latter...

Suppose you have several OLE files and you open the DB. If your DB has grown to 500 Mb, your SWAP FILE has to also be 500 Mb + the size of everything else that Windows wants to store in memory in a running system. Which is VERY OFTEN another 100 Mb or so. You might well have that much disk set aside, but beware of the need to keep your disk defragged if you are going this way.
 
Man that sounds like a lot! All I want to use it for is: I'm creating a program in C++ that organizes a bunch of different forms that we use around the office. I would like to keep the number of files down to a minimum, which is why I asked about storing them in Access. My goal would be to: allow the user to add a form to the database for later use. and have a search box in the program which lists the forms currently in the DB. And if the user wants they may open a form to print or whatever.

I think I stepped in over my head when I asked that though. I create programs all day long which interact with databases's, but never have attempted storing actual files in them.

Do you know of any online tutorials? Thanks!
 

Users who are viewing this thread

Back
Top Bottom