<%@ Language="VBScript" %> <% Option Explicit %> <% 'declare your variables Dim rs, linkId, linkLocation,fs,f, adoStream, dataSize, dataPosition, chunkSize Dim sSQL, returnString 'Receiving values from Form, assign the values entered to variables linkId = Request("linkId") 'declare SQL statement that will query the database sSQL = "getLinkLocation " sSQL = sSQL + " @linkId = '" + CStr(linkId) + "'" sSQL = sSQL + " ,@customerId = '" + CStr(customerId) + "'" Set rs = Server.CreateObject("ADODB.Recordset") 'Open the connection to the database connection.Open(sConnString) rs.open sSQL, connection While Not rs.EOF linkLocation = rs("webLink") rs.MoveNext Wend 'response.write "sql is " & sSQL 'Done. Close the connection object rs.close Set rs = Nothing connection.Close Set connection = Nothing if (linkLocation = "") then response.redirect "customerHome.asp" else linkLocation = Server.MapPath(linkLocation) Set fs=Server.CreateObject("Scripting.FileSystemObject") Set f=fs.GetFile(linkLocation) Set adoStream = CreateObject("ADODB.Stream") adoStream.Open() adoStream.Type = 1 adoStream.LoadFromFile(f.Path) dataSize = f.size Response.Buffer = true Response.clear Response.ContentType = "application/x-unknown" ' arbitrary Response.AddHeader "Content-Length", dataSize Response.AddHeader "Content-Disposition", "attachment; filename=" &f.name Response.flush dataPosition = 0 chunkSize = 4194304 do while dataPosition < dataSize Response.BinaryWrite adoStream.Read() Response.flush dataPosition = dataPosition + chunkSize loop end if %>