Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am contemplating a new project for my personal use. I want to scan a document into a .pdf file and store that info into a sql database by filename. Then recall using part of the filename, and display it on the screen. I haven't even started to write any code yet.
It's still just a thought in my mind. I just want to be sure it's possible before I start swinging at windmills.


What I have tried:

Nothing yet, It's still just a thought in my mind. I just want to be sure it's possible before I start swinging at windmills.
Posted
Updated 7-Feb-21 22:29pm
Comments
Luc Pattyn 7-Feb-21 16:44pm    
If you're not sure it can be done, how can you even begin to hope you could do it???
Member 10376725 8-Feb-21 7:47am    
That's a rather silly question from a "developer". There are a lot of things I wasn't sure that I could do in the past, I am a visionary and succeeded in accomplishing them all.
Dave Kreskowiak 7-Feb-21 16:55pm    
Sure, it's possible. The practicality of such remains a question though.

Yes, it can be done - SQL doesn't care what data columns contain, as long as you store it in the right type of column.

PDF files are either 8-bit binary files or 7-bit ASCII text files, so the safest thing to do is store them in a VARBINARY column and pass the data through via a parameterised query, along with the filename.

You can then retrieve it with an LIKE query on the filename:
SQL
SELECT ... WHERE FileNameColumn LIKE '%March 2020%'
will return any filename with the text "March 2020" in it, for example. Again - obviously - a parameterised query is mandatory!

When you do that, you have the data in a byte array, and can display in whatever you need to.
 
Share this answer
 
Comments
Member 10376725 8-Feb-21 8:20am    
thanks OriginalGriff, that will get me started. And thank you for taking the time to give me a real solution, instead of a smartarse comment.
My personal preference is to store the file on our file system and just record the name and location of the file on the actual database (I also store other information such as version number, date amended, author etc). Saves having to handle the byte array but does "disconnect" the data. As I said, personal preference.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900