Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie help: inserting pdf files into SQL field

Status
Not open for further replies.

ije

MIS
Jun 10, 2002
38
0
0
AU
Hoping someone can help.....I need to insert via VBScript a PDF file into a SQL table. I have not done this, and need to create the table, and the script to do the job.

The table it is going into will have 2 fields - a text field to desribe the attachment, and the attachment field.

Of course, once it is in, I need to be able to display the doc, using VB Script.

I know this may be a lot to ask, but is someone kind enough to assist?

[afro2] ije [afro2]
 
i dont think so you can insert pdf file directly into the column, try this

its better you handle this at script level.
when you need to insert the pdf file into table, just copy that file to any specific location on the server using vbscript and insert that path into the sql server table,

so when ever you need to retrieve the file just pick the path from table and open the file.



Kishore
 
i dont think so you can insert pdf file directly into the column, try this

its better you handle this at script level.
when you need to insert the pdf file into table, just copy that file to any specific location on the server using vbscript and insert that path into the sql server table,

so when ever you need to retrieve the file just pick the path from table and open the file.

its better you create a folder in a secure place to protect files from direct file handling from OS

Kishore
 
I don't have the code needed to do this, however you can put the file in a field with the datatype of image. This will accept large amounts of binary data.

If you search google for how to put an image into a database field, that should get you where you need to be.

Denny
 
You take a MASSIVE performance hit to insert a file as a BLOB into a database.

If you are doing it in VBScript you will need to do a binary read to get the file into a VB variable, then insert that.

Check out this site about it.

Generally speaking the cost of converting it to binary to insert it, the converting it back from binary to read it later is so high that it outweighs the security benefit of storing the file in the database.

I have to agree with the posts above, you are far better off storing the files in a directory that has read and write but not execute priviledges and simply store the location in the database.

"Every day is like a precious gift, you have to make it count" James Birrell 1993-2001
 
thanks for responses - i accept that this is not the ideal solution, but due to customer lockdown on file shares, we can come up with no other alternative.

I was hoping for a simple example of how to insert into the table. I imagine it is similar to ( my psuedo code here...)
insert into imagetable(description,file) values ("work procedure",c:\file.pdf)

I know that is not right, but that is all I am after, and the same with retrieving it - how to select or lauch the pdf in a Windows (not ASP) environment.

Please please please.....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top