Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 7th, 2008, 9:15 PM   #1
Robocop
Programmer
 
Join Date: Sep 2004
Posts: 47
Rep Power: 0 Robocop is on a distinguished road
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
Robocop is offline   Reply With Quote
Old Feb 8th, 2008, 2:12 AM   #2
PhilBon
Hobbyist Programmer
 
PhilBon's Avatar
 
Join Date: Nov 2005
Posts: 172
Rep Power: 3 PhilBon is on a distinguished road
Send a message via AIM to PhilBon Send a message via MSN to PhilBon
Re: Saving document into database

Why don't you just store the files on the server and put in the path in the database?
PhilBon is offline   Reply With Quote
Old Feb 8th, 2008, 7:26 AM   #3
Jabo
Not a user?
 
Join Date: Sep 2007
Posts: 272
Rep Power: 2 Jabo is on a distinguished road
Re: Saving document into database

Then if the file should get moved?
Jabo is offline   Reply With Quote
Old Feb 8th, 2008, 9:09 AM   #4
PhilBon
Hobbyist Programmer
 
PhilBon's Avatar
 
Join Date: Nov 2005
Posts: 172
Rep Power: 3 PhilBon is on a distinguished road
Send a message via AIM to PhilBon Send a message via MSN to PhilBon
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.
PhilBon is offline   Reply With Quote
Old Feb 8th, 2008, 9:19 AM   #5
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,885
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Re: Saving document into database

Quote:
Originally Posted by Robocop View Post
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.
Sane is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Storing BLOBs in a database - problem jonyzz Other Programming Languages 8 Jan 31st, 2007 4:38 AM
searching an access database? designXperts.net Visual Basic .NET 12 Nov 27th, 2005 5:03 PM
Saving data to a database a02227 Visual Basic .NET 2 Apr 21st, 2005 2:35 AM
Using ODBC to connect to a remote database in a C program bigi C++ 1 Mar 8th, 2005 3:19 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:25 AM.

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