PDA

View Full Version : Download files from SQL failing


bill wolf
12-27-2010, 05:41 PM
I just signed up for a DiscountASP account and the following snippet worked on my old host.

The purpose of the script is to extract binary data from my SQL 08 DB and display a file download dialog to save or open. IE8 is spitting out the generic "IE cannot display the webpage" error.

<!--#include file="includes/data.asp"-->
<%
If Session("LoginID") <> "" Then
SQL = "SELECT * FROM dbo.GELeaseFileDocuments where dbo.GELeaseFileDocuments.DocumentID = " & Request.QueryString("id")
rs.open sql, cn, 3, 1

Response.ContentType = "application/octet-stream"
' let the browser know the file name
Response.AddHeader "Content-Disposition", "attachment;filename=" & Trim(rs("DocumentName"))
' let the browser know the file size
Response.AddHeader "Content-Length", rs("FileSize")
Response.BinaryWrite rs("Document")
rs.close
Else
Response.write ("Download Failed.")
End If
%>

bill wolf
12-27-2010, 05:58 PM
Resolution: commented out content length.

I just signed up for a DiscountASP account and the following snippet worked on my old host.

The purpose of the script is to extract binary data from my SQL 08 DB and display a file download dialog to save or open. IE8 is spitting out the generic "IE cannot display the webpage" error.

<!--#include file="includes/data.asp"-->
<%
If Session("LoginID") <> "" Then
SQL = "SELECT * FROM dbo.GELeaseFileDocuments where dbo.GELeaseFileDocuments.DocumentID = " & Request.QueryString("id")
rs.open sql, cn, 3, 1

Response.ContentType = "application/octet-stream"
' let the browser know the file name
Response.AddHeader "Content-Disposition", "attachment;filename=" & Trim(rs("DocumentName"))
' let the browser know the file size
Response.AddHeader "Content-Length", rs("FileSize") Response.BinaryWrite rs("Document")
rs.close
Else
Response.write ("Download Failed.")
End If
%>

wisemx
12-28-2010, 03:44 AM
Wow, good job, I would have missed that. ;-)

bill wolf
12-28-2010, 06:02 AM
Thanks.

There's no rush like frantic testing and debugging during a migration.