Dean
05-28-2004, 09:37 AM
Hi thier
I am in the process of re-coding a .asp page that i have that i currently have a custom header set up in iis5 so that it is issued from the server as a csv.
I have the code so that i can create this custom header on the page and so do not need to use IIS5 to get it issue as the required CSV.
What i am trying to do is as this page currently is getting files from a database is that i want to be able to alter the name and the mime type for the file by adding dynamic elements into the custome header tag for the page. This way the link I click currently use to generate the CSV file I can chage to a form and the i can name the file and choose between actually having the file as a .csv, .xls. htm anything I like.
currently i have everything i place but when i put the<%= recordset.item."(filename").vale%> into the code it doesn't work I have tried removing the <%= & %> from either end as it is in a <% & %> for the custom header any way then i have swapped the " for ' as it is a value within a set of " " but it is still not getting the file name i want.
here is the code i have currently that If i can get it read the dynamics for the header tag should do exactly what i want.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../../Connections/database.asp" -->
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "1"
If (Request.QueryString("FileID") <> "") Then
Recordset1__MMColParam = Request.QueryString("linkID")
End If
%>
<%
Dim Recordset1
Dim Recordset1_numRows
Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_clickserve_STRING
Recordset1.Source = "SELECT * FROM link WHERE FileID = " + Replace(Recordset1__MMColParam, "'", "''") + ""
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()
Recordset1_numRows = 0
%>
<%
Response.AddHeader "Content-disposition","attachment; filename=(Recordset1.Fields.Item('filename').Value).(Recordset1.Fields.Item('filetype').Value)"
%>
<%
Dim F, Head
For Each F In Recordset1.Fields
Head = Head & ", " & F.Name
Next
Head = Mid(Head,3) & vbCrLf
Response.ContentType = "text/plain"
Response.Write Head
Response.Write Recordset1.GetString(,,", ",vbCrLf,"")
%>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
any suggestions welcome as I now it is sonething silly as i am tired which is why it is doing my head in.
I am in the process of re-coding a .asp page that i have that i currently have a custom header set up in iis5 so that it is issued from the server as a csv.
I have the code so that i can create this custom header on the page and so do not need to use IIS5 to get it issue as the required CSV.
What i am trying to do is as this page currently is getting files from a database is that i want to be able to alter the name and the mime type for the file by adding dynamic elements into the custome header tag for the page. This way the link I click currently use to generate the CSV file I can chage to a form and the i can name the file and choose between actually having the file as a .csv, .xls. htm anything I like.
currently i have everything i place but when i put the<%= recordset.item."(filename").vale%> into the code it doesn't work I have tried removing the <%= & %> from either end as it is in a <% & %> for the custom header any way then i have swapped the " for ' as it is a value within a set of " " but it is still not getting the file name i want.
here is the code i have currently that If i can get it read the dynamics for the header tag should do exactly what i want.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../../Connections/database.asp" -->
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "1"
If (Request.QueryString("FileID") <> "") Then
Recordset1__MMColParam = Request.QueryString("linkID")
End If
%>
<%
Dim Recordset1
Dim Recordset1_numRows
Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_clickserve_STRING
Recordset1.Source = "SELECT * FROM link WHERE FileID = " + Replace(Recordset1__MMColParam, "'", "''") + ""
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()
Recordset1_numRows = 0
%>
<%
Response.AddHeader "Content-disposition","attachment; filename=(Recordset1.Fields.Item('filename').Value).(Recordset1.Fields.Item('filetype').Value)"
%>
<%
Dim F, Head
For Each F In Recordset1.Fields
Head = Head & ", " & F.Name
Next
Head = Mid(Head,3) & vbCrLf
Response.ContentType = "text/plain"
Response.Write Head
Response.Write Recordset1.GetString(,,", ",vbCrLf,"")
%>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
any suggestions welcome as I now it is sonething silly as i am tired which is why it is doing my head in.