Hi,
I am running a batch file to generate a report. A command similar to the below one is put in the batch file.
http://localhost/XXXX/XXXX/Test.asp?format=EXCEL&cqs=N3-FMIJTUVMUTPO-QQEWQ3MP
Test.asp contains the below
<%@ Language=VBScript %>
<%
select case Request.QueryString("format")
case "EXCEL", "Excel", "excel":
Response.ContentType = "application/vnd.ms-excel"
case "WORD", "Word", "word":
Response.ContentType = "application/msword"
case else:
Response.ContentType = "text/html"
end select
'Get the hostname
Dim ServerHostName
ServerHostName = Request.ServerVariables("SERVER_NAME")
%>
<html>
<head>
<title>XXXX</title>
<link REL="stylesheet" HREF="http://<%=ServerHostName%>/XXXXASP/DATA/Style.css" type="text/css"></link>
<%
dim sCqs
sCqs = Request.QueryString("cqs")
' Open the spf data db
Set m_DataDB = Server.CreateObject("ADODB.Connection")
m_DataDB.ConnectionString=Application("NotiaDatabase")
m_DataDB.Open
dim sView
sView = "TEST_VW"
' Get the column headers to be displayed
dim sQueryH
sQueryH = "select * from tablename"
dim rsQueryH
set rsQueryH = m_DataDB.Execute(sQueryH)
if not rsQueryH.EOF then rsQueryH.MoveFirst
dim rsQueryH2
dim sQueryH2
dim cCols
sQueryH2 = "select * from USER_TAB_COLUMNS "
set rsQueryH2 = m_DataDB.Execute(sQueryH2)
if not rsQueryH2.EOF then rsQueryH2.MoveFirst
sCols = rsQueryH2.Fields(0)
rsQueryH2.MoveNext
while not rsQueryH2.EOF
sCols=sCols & "," & rsQueryH2.Fields(0)
rsQueryH2.MoveNext
wend
' Form the query for the report
dim sQuery1
sQuery1 = "SELECT " & sCols
sQuery1 = sQuery1 & " FROM " & sView
sQuery1 = sQuery1 & " where Config like '" & sCqs & "%'"
sQuery1 = sQuery1 & " order by 1,2,4"
dim rsQuery1
set rsQuery1 = m_DataDB.Execute(sQuery1)
if not rsQuery1.EOF then rsQuery1.MoveFirst
%>
</head>
<body>
<div class="reportTitle"> Report</div>
<hr WIDTH="100%">
<table WIDTH="100%">
<tr class="reportItemHeader">
<%
for each y in rsQuery1.Fields
response.write("<th>" & y.name & "</th>")
next
%>
</tr>
<%
' Counter for shading every other row
dim nCount
nCount = 1
dim sRowStyle
' Loop through each record in the select
rsQuery1.MoveFirst
do until rsQuery1.EOF
if nCount mod 2 = 1 then
sRowStyle = "reportItemOdd"
else
sRowStyle = "reportItemEven"
end if
response.write("<tr class='" & sRowStyle & "'>")
for each y in rsQuery1.Fields
response.write("<td>" & y.value & "</td>")
next
rsQuery1.MoveNext
nCount = nCount + 1
response.write("</tr>")
loop
%>
</table>
</body>
</html>
The batch file is usually run during the night time and it opens a 'File Download' dialog box which needs manual intervention. I would like to automate the file download to a preset location.
Please let me know the code to be added in the asp file so that i can automate the file download.
Regards,
Dinil