I've been working on a reporting tool to summarize and link data from our Call Center system (CCS) and our bug tracking system. The tool is written in vbscript and classic ASP. One thing I have been trying to get working is retrieving attachments from the CCS. They are stored in a SQL server database as follows:
TABLE Attachment {
AttachmentID (PK, uniqueidentifier, not Null)
Filename (varchar(250))
AttachmentData (varbinary(max))
}
What I tried to do, was pass the AttachmentID guid to a simple ASP page that would retrieve the data then output it directly as a file download. When I click on the link, I get a "File Not Found" error. My code is here:
<%
a_strConn = session("ClienteleConn")
Set a_DBObj = Server.CreateObject("ADODB.Connection")
a_DBObj.Open(a_strConn)
q_getAttachment="select FileName, AttachmentData from Attachment "_
&"where AttachmentID='"&request("docGUID")&"'"
set rsAttachmentData=a_DBObj.execute(q_getAttachment)
Response.Contenttype="application/octet-stream"
Response.AddHeader "Content-disposition","attachment;filename=" &rsAttachmentData("FileName")
response.BinaryWrite(rsAttachmentData("AttachmentData"))
response.end
%>
Is there a "simple" solution that still uses vbscript? Most of the samples I've found are using C# or ASP.NET.