How to open a word document saved in sql server in asp.net

  • Thread starter Thread starter jefftim
  • Start date Start date
J

jefftim

Hi All

I've saved a word document in sql server database.I'm able to retrieve
it from the database and open it in a word application.
My problem is as i have to use this in an intranet application, the
word is not opening in a client machine but it is opening on the
machine the application has been hosted.

I'm extracting the word file from database and storing it on the hard
disk and in the next instance passing the file location to the shell
command and opening it.

please try to solve my problem asap.

Jeff
 
One (of many) solutions:
when the document is retrieved from the database, save it to a temporary
file on the webserver. Then have the webpage redirect to the file. This
will cause the Word document to be opened in the web browser.
 
Thank u Brendan for the suggestion. I've already tried this one. Its
working on the server but not on the client. If you have any other
solution try to post it.
I've used response.binarywrite also.

Jeff
 
You may try this:

byte[] btYourDoc;
btYourDoc = GetYourDocDataFromSqlServer();
Response.ContentType = "application/ms-word";
Response.AddHeader("Content-Disposition",
"attachment;filename=yourfilename.doc");
Response.BinaryWrite(btYourDoc);
Response.End();
 
Hi Danny

Thanx for the code.its working
Danny said:
You may try this:

byte[] btYourDoc;
btYourDoc = GetYourDocDataFromSqlServer();
Response.ContentType = "application/ms-word";
Response.AddHeader("Content-Disposition",
"attachment;filename=yourfilename.doc");
Response.BinaryWrite(btYourDoc);
Response.End();
Hi All

I've saved a word document in sql server database.I'm able to retrieve
it from the database and open it in a word application.
My problem is as i have to use this in an intranet application, the
word is not opening in a client machine but it is opening on the
machine the application has been hosted.

I'm extracting the word file from database and storing it on the hard
disk and in the next instance passing the file location to the shell
command and opening it.

please try to solve my problem asap.

Jeff
 

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

Back
Top