Open binary file directly from BLOB

B

Bishman

Hi,

Can someone suggest the best technique / method of opening a Word ( or any
other ) Document from an SQL BLOB ?

I have the process of saving and retrieveing the file from an SQL Binary
field working fine, but the user 'saves' the file from the Binary field to a
binary disk file and can then open it. It would be better for them to be
able to just open the file directly for viewing etc. I can 'trigger' a load
for the file myself, but Im sure there must be a 'slick' method using some
sort of 'memory' files, without needing to explicitly write the file to
disk first ?

One Issue I can forsee is determining the application required to open the
file. Also what would happen if the user modified and tried to save it ? Or
do you just use a 'viewer' / view only mode ?

Is saving it to disk first actually the required technique ?

Thanks in advance.

Jon
 
N

Nicholas Paldino [.NET/C# MVP]

Jon,

It pretty much is. You could probably load a new Word document, and
then query it for the IPersistMemory interface. If it supports that, then
you can feed the contents into Word from memory. However, you would have to
manage when it is saved (since there is no option in Word to save the file
to memory, only to disk), calling the Save method on the IPersistMemory
interface yourself when you wanted to commit the contents back to memory.

Hope this helps.
 
B

Bishman

Thanks ( again ) Nicholas

Shame there is nothing 'slicker' but then its good in one way as its less
for me to code !!

Cheers for the response

Jon


Nicholas Paldino said:
Jon,

It pretty much is. You could probably load a new Word document, and
then query it for the IPersistMemory interface. If it supports that, then
you can feed the contents into Word from memory. However, you would have
to manage when it is saved (since there is no option in Word to save the
file to memory, only to disk), calling the Save method on the
IPersistMemory interface yourself when you wanted to commit the contents
back to memory.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Bishman said:
Hi,

Can someone suggest the best technique / method of opening a Word ( or
any other ) Document from an SQL BLOB ?

I have the process of saving and retrieveing the file from an SQL Binary
field working fine, but the user 'saves' the file from the Binary field
to a binary disk file and can then open it. It would be better for them
to be able to just open the file directly for viewing etc. I can
'trigger' a load for the file myself, but Im sure there must be a 'slick'
method using some sort of 'memory' files, without needing to explicitly
write the file to disk first ?

One Issue I can forsee is determining the application required to open
the file. Also what would happen if the user modified and tried to save
it ? Or do you just use a 'viewer' / view only mode ?

Is saving it to disk first actually the required technique ?

Thanks in advance.

Jon
 
C

chanmm

Bishman,

Maybe it will be easy to handle if you leave those Word files to the OS and
keep a link in DB.

chanmm

Bishman said:
Thanks ( again ) Nicholas

Shame there is nothing 'slicker' but then its good in one way as its less
for me to code !!

Cheers for the response

Jon


Nicholas Paldino said:
Jon,

It pretty much is. You could probably load a new Word document, and
then query it for the IPersistMemory interface. If it supports that,
then you can feed the contents into Word from memory. However, you would
have to manage when it is saved (since there is no option in Word to save
the file to memory, only to disk), calling the Save method on the
IPersistMemory interface yourself when you wanted to commit the contents
back to memory.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Bishman said:
Hi,

Can someone suggest the best technique / method of opening a Word ( or
any other ) Document from an SQL BLOB ?

I have the process of saving and retrieveing the file from an SQL Binary
field working fine, but the user 'saves' the file from the Binary field
to a binary disk file and can then open it. It would be better for them
to be able to just open the file directly for viewing etc. I can
'trigger' a load for the file myself, but Im sure there must be a
'slick' method using some sort of 'memory' files, without needing to
explicitly write the file to disk first ?

One Issue I can forsee is determining the application required to open
the file. Also what would happen if the user modified and tried to save
it ? Or do you just use a 'viewer' / view only mode ?

Is saving it to disk first actually the required technique ?

Thanks in advance.

Jon
 
B

Bishman

Yeah, I have seen other people advise this as well and its a fair
point.....to which I dont really have a particuarly strong response other
than the DB gets treated with a degree of respect from the backup and
security point of view, and it does provide that almost 'physical ' link
between the rest of the data associated with the BLOB and the BLOB itself.


chanmm said:
Bishman,

Maybe it will be easy to handle if you leave those Word files to the OS
and keep a link in DB.

chanmm

Bishman said:
Thanks ( again ) Nicholas

Shame there is nothing 'slicker' but then its good in one way as its less
for me to code !!

Cheers for the response

Jon


Nicholas Paldino said:
Jon,

It pretty much is. You could probably load a new Word document, and
then query it for the IPersistMemory interface. If it supports that,
then you can feed the contents into Word from memory. However, you
would have to manage when it is saved (since there is no option in Word
to save the file to memory, only to disk), calling the Save method on
the IPersistMemory interface yourself when you wanted to commit the
contents back to memory.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Hi,

Can someone suggest the best technique / method of opening a Word ( or
any other ) Document from an SQL BLOB ?

I have the process of saving and retrieveing the file from an SQL
Binary field working fine, but the user 'saves' the file from the
Binary field to a binary disk file and can then open it. It would be
better for them to be able to just open the file directly for viewing
etc. I can 'trigger' a load for the file myself, but Im sure there must
be a 'slick' method using some sort of 'memory' files, without needing
to explicitly write the file to disk first ?

One Issue I can forsee is determining the application required to open
the file. Also what would happen if the user modified and tried to save
it ? Or do you just use a 'viewer' / view only mode ?

Is saving it to disk first actually the required technique ?

Thanks in advance.

Jon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top