Saving image data type record to computer

  • Thread starter Thread starter Chuck
  • Start date Start date
C

Chuck

On 2-4-2005 9:05, I asked how I could open an image file ( a Word document
actually) from an SQL table with VBA code. This would be similar to opening
the table, right-clicking the record and choosing the "Document Object |
Open" menu item.

I got one response saying that that is probably not possible and after
searching for quite a while, I would probably have to agree.

So I guess I would have to save the file to the user's computer first and
then open it with Word automation. I have found code that works to save a
binary data type to the desktop (see below) but it does not work with an
image type, at least not when the image type is a Word document. The file
saved to the computer is not readable by Word. So how can I save an image
type object to the desktop (from an ADP project with SQL backend using ADO)?
Thanks

I guess I could save the Word file as a binary data type but I would prefer
to use an image type since I can simply drag-and-drop the document into the
table. I can't do that with a binary data type.

' Code to save binary record to computer.
Set BinaryStream = CreateObject("ADODB.Stream")
BinaryStream.Type = adTypeBinary
BinaryStream.Open
BinaryStream.Write Request.BinaryRead(Request.TotalBytes)
BinaryStream.SaveToFile "c:\myfile.doc", adSaveCreateOverWrite
 
Hi Chuck,

When I answered your previous question I assumed you intended to store
the contents of the Word documents in a BLOB field in a SQL Server
table. But from what you're saying about an "image type object" I guess
you're thinking in terms of embedding the document in an OLE field (or
whatever the SQL Server equivalent is). The difference is that if you
embed the document you don't just store the contents of the file but a
package that also contains information about its parent app, an icon
and/or picture of the first page, and so on. This means that if you
write the contents of the field to disk, you don't get a usable
document.

I don't know what facilities are offered by ADP+SQL Server, but with
MDB+Jet the least inconvenient way to access an embedded document is to
use an ObjectFrame control on a form. By manipulating the Verb and
Action properties of the ObjectFrame you can open the document in its
parent application, either within the frame or in a separate window. IOW
you can open the document without having to save it to disk - but if you
do want to save it to disk you have to do it by automating the parent
application.
 
John,

You learn something new everyday! As I was researching this problem, the
word BLOB kept coming up. You mention it in your post as well. This is the
first time I have heard of this term so I looked it up:

Portion of Microsoft Article:
"From a database perspective, a binary data object is known as a binary
large object, or BLOB. As the acronym suggests, this type of data can take
up a lot of space. Using the image, text, or ntext data types, SQL Server
can store binary data in tables. Table 1, page 32, lists the attributes of
the data types that SQL Server can use for BLOB storage. The image data
type is the primary BLOB-storage data type; you can use it to hold virtually
any type of binary data."

From that definition, I would say that the image data type I'm using is a
BLOB field....bit I'm not sure. In any case I guess it would be much
simpler if I save the word doc as a binary data type instead of image. That
means I lose the drag-and-drop functionality and will need to import the
document with code. Not ideal but workable.


Thanks again.

Chuck
 
I expect it will be possible to achieve drag-n-drop in code; Access
forms don't provide it as standard, but it's worth a web search.

As of now, you know more about SQL Server and BLOBs than I do. Good
luck!


John,

You learn something new everyday! As I was researching this problem, the
word BLOB kept coming up. You mention it in your post as well. This is the
first time I have heard of this term so I looked it up:

Portion of Microsoft Article:
"From a database perspective, a binary data object is known as a binary
large object, or BLOB. As the acronym suggests, this type of data can take
up a lot of space. Using the image, text, or ntext data types, SQL Server
can store binary data in tables. Table 1, page 32, lists the attributes of
the data types that SQL Server can use for BLOB storage. The image data
type is the primary BLOB-storage data type; you can use it to hold virtually
any type of binary data."

From that definition, I would say that the image data type I'm using is a
BLOB field....bit I'm not sure. In any case I guess it would be much
simpler if I save the word doc as a binary data type instead of image. That
means I lose the drag-and-drop functionality and will need to import the
document with code. Not ideal but workable.


Thanks again.

Chuck
 
Back
Top