Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   ASP.NET (http://www.programmingforums.org/forum35.html)
-   -   Saving document into database (http://www.programmingforums.org/showthread.php?t=15138)

Robocop Feb 7th, 2008 9:15 PM

Saving document into database
 
I'm looking for help on how to save .doc and .pdf documents into a database, and then after that, be able to retrieve the text into a textbox.

I've read around, and saw it can be done by converting the document into a binary data type, but I have no idea how this can be done.

I'm using ASP with C# and SQL Server 2005.

Please Help

PhilBon Feb 8th, 2008 2:12 AM

Re: Saving document into database
 
Why don't you just store the files on the server and put in the path in the database?

Jabo Feb 8th, 2008 7:26 AM

Re: Saving document into database
 
Then if the file should get moved?

PhilBon Feb 8th, 2008 9:09 AM

Re: Saving document into database
 
If the file gets moved then you either make a program to move it that will also update the database or you update the database on your own.

Sane Feb 8th, 2008 9:19 AM

Re: Saving document into database
 
Quote:

Originally Posted by Robocop (Post 140826)
it can be done by converting the document into a binary data type

It does not have much to do with "converting" the file to a binary data type. The PDF document is already a binary file.

What you need to do is write a script to insert a text file into a column. However, there are two changes you need to make apart from that routine process.

1) Make that column type "BINARY".

:

BINARY(M)
The BINARY type is similar to the CHAR type, but stores binary strings rather than non-binary strings. This type was added in MySQL 4.1.2.


2) When you are reading in the PDF document, make sure your read handle is opened with the "rb" (read binary) format, rather than the typical "r" or "rt" (read text) format.


Getting back on track, you said you want to retrieve the document from the database, and display it in a textbox. If you're using a textbox to display the output, then you don't want the binary. It seems you just want the text.

You might need to find some .doc and .pdf libraries that could do the processing and plaintext fetching for you. But converting a fully formatted document with pictures and a layout, into simple plaintext, is a very difficult task.


All times are GMT -5. The time now is 12:51 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC