Home All Groups Group Topic Archive Search About

RE: Retrieve a Blob from database and show it to the user

Author
8 Nov 2006 8:31 PM
derek
If you have the byte array of the file, open a filestream using the same
filename you have stored in the database.

ex:
('data' is the byte array of the file you have already retrieved from the
database)

System.IO.FileStream fs = new System.IO.FileStream(fileNameFromDataBase,
System.IO.FileMode.Create);

fs.Write(data, 0, data.Length);  // here is where you will write the byte
array
fs.Close();


then to open the file with an associated program, use the Process class and
only pass it the name of the file you used above

ex:
System.Diagnostics.Process.Start(fileNameFromDataBase);

The examples above i wrote in 2.0, but it should work the same for 1.1

Show quote
"sameer" wrote:

> Hi all,
>
> application :
> .net framework 1.1
> winforms done in vb.net using webservice over the internet to connect to sql
> server 2000
> field used in the databse to store the documents\ images : IMAGE
>
> i am doing a small document managment module in my application here and
> these are the requirement
>   a. let the user select a document from the winforms application and save
> it to the database - for this i converts this document into a byte array,
> shove it into a dataset, send it across the webservice and store it in the
> database. webserivce part is totally irrelevant but just wanted to mention
> that in case u think it might make a difference anywhere. this part is
> programmed and already done.
>
>  b. Show the saved document in the database to the user when the user cliks
> on the name of the document in the appilcation - this is what i am not able
> todo. All I have done so far is get the document from the database into a
> ado.net datatable of datatype byte array and i think( correct me if i am
> wrong) after that i will have to  open a filestream from this byte array and
> then do something ...,in the end i want to pop open this document to the user
> so that he can read it i.e each document is of a different type i.e .doc,
> .txt, .xls or images, for which i will have to open them in their own
> software i.e wrod for doc, excel for xls and so on. How can i do this, if
> anybody can point me to some code references that would be great.
>
> thanks
> sameer

AddThis Social Bookmark Button