How to import data from SQL database to MS Excel by ASP.For example, already added a long list of contact people (name, phone, email, address...) in a table on the SQL server, how can I just upload the file from the table on the SQL server to transfer the data to the excel file by ASP code, but it must using parameters date, year and month?Any help will be most appreciated!----file1.asp----<form id="form1" name="form1" action="file2.asp" method="post"><table border="0" width="600" cellspacing="1" cellpadding="0"><tr><td width="140" class="CellHeader">Tanggal</td><td width="450"><SELECT id=selectmonth name=selectmonth><%for I = 01 to 12Response.Write(vbNewLine)if I = Month(date) thenResponse.Write("<OPTION selected value=" & MonthName(I) & ">" & MonthName(I) & "</OPTION>")elseResponse.Write("<OPTION value=" & MonthName(I) & ">" & MonthName(I) & "</OPTION>")end ifnext%></SELECT> <SELECT id=selectyear name=selectYear><%for I = 2000 to 2111Response.Write(vbNewLine)if I = Year(date) thenResponse.Write("<OPTION selected value=" & I & ">" & I & "</OPTION>")elseResponse.Write("<OPTION value=" & I & ">" & I & "</OPTION>")end ifnext%> </SELECT></td></table><input type="submit" name="submit" value="Generate!"></form>-----file2.asp----- varBln = Request("selectmonth") varthn = Request("selectyear") dim rstStt, cmdSP, parSP set rstStt = server.CreateObject("ADODB.Recordset") set cmdSP = server.CreateObject("ADODB.Command") cmdSP.ActiveConnection =con5 cmdSP.CommandType = 4 cmdSP.CommandText = "vof_generateRisk" cmdSP.Parameters.Refresh Response.ContentType = "application/vnd.ms-excel" Response.AddHeader "Content-Disposition", "attachment; filename=Excel" & request.form("objTable") & ".xls"
Hmmm....