Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Retrieve pdf files from SQL Server

Reply
Thread Tools

Retrieve pdf files from SQL Server

 
 
Jeff Fenn
Guest
Posts: n/a
 
      02-27-2004
Hi

Doesn anyyone know the proper lines of ASP code to sucessfully retrieve a pdf file from SQL server. Everytime I run my code I get gibberish all over the screen. I would like it to prompt me to save the file to disk

Thanks

-Jeff
 
Reply With Quote
 
 
 
 
Patrick G.
Guest
Posts: n/a
 
      02-27-2004
I don't know if this is what your looking for but see code below

I use this in a file called getfile.asp. On a web page listing documents (of
any type really) you would click a link to the getfile.asp sending the file
name and an action in the querystring.

For this example sending Now or Later as the action will either do the Save
As prompt or will open the document in the browser window.

There is also a call to a stored proc that will track the amount of times
the file was accessed.

Hope this helps.
=================
Dim strFile, strFileAction

strFile = Request.QueryString("file")
strFileAction = Request.QueryString("action")

If strFile <> "" Then
Call ExecQuery(connString, "EXEC procPublic_LibFileClick '" & strFile &
"'")
If strFileAction = "later" Then
'On Error Resume Next

Dim strFilePath, strFileSize, strFileExt, strFileType
Dim objSendFile

strFilePath = Server.MapPath(strFile)
'Response.Write strFilePath

'Set objSendFile = Server.CreateObject("Persits.Upload")
'objSendFile.SendBinary strFilePath, True, "application/octet-stream",
True

Set objSendFile = Server.CreateObject("ADODB.Stream")
objSendFile.Open
objSendFile.LoadFromFile strFilePath

Response.ContentType = "xxx/xxx"
Response.AddHeader "content-disposition", "attachment; filename=" &
strFile
Response.BinaryWrite objSendFile.ReadText
Set objSendFile = Nothing

If Err.Number <> 0 Then
'Call TrapError(Err.Number, Err.Description, Err.Source)
End If
ElseIf strFileAction = "now" Then
With Response
.Write "<html><head></head><body onload=""window.document.location='" &
strFile & "'""></body></html>"
End With
End If
End If


"Jeff Fenn" <> wrote in message
news:749874D3-B39E-44E0-9CAA-...
> Hi,
>
> Doesn anyyone know the proper lines of ASP code to sucessfully retrieve a

pdf file from SQL server. Everytime I run my code I get gibberish all over
the screen. I would like it to prompt me to save the file to disk.
>
> Thanks.
>
> -Jeff



 
Reply With Quote
 
 
 
 
Jeff
Guest
Posts: n/a
 
      03-01-2004
Thanks, that worked.
 
Reply With Quote
 
Patrick G.
Guest
Posts: n/a
 
      03-02-2004
Glad to hear... good luck.

"Jeff" <> wrote in message
news:663724A5-80E8-47B9-87B4-...
> Thanks, that worked.



 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help. Getting a An error has occurred while establishing a connectionto the server. When connecting to SQL Server 2005, this failure may be causedby the fact that under the default settings SQL Server does not allow remote aboutjav.com@gmail.com ASP .Net 0 05-03-2008 12:43 PM
Postscript to PDF with pdf-tools, pdf-writer, or other Sean Nakasone Ruby 1 04-14-2008 09:13 PM
PDF::Writer, create pdf and insert in other pdf file. Ricardo Pog Ruby 1 03-26-2008 08:24 PM
reading pdf files from a folder and place it in the sql server dat =?Utf-8?B?U3JpZGhhcg==?= ASP .Net 3 12-13-2005 01:28 PM
Retrieve SQL Server 2000 rights for a user Robert Wehofer ASP .Net 0 11-12-2003 03:29 PM



Advertisments