|
JohnH -> RE: Exporting to Excel (7/29/2005 9:52:17)
|
Can anyone else help, my code is below <%
Session.lcid = 2057
%>
<%
Dim DSN, RS, SQL, Conn
SQL = "SELECT A.STAFFNO AS 'Staff number', +ISNULL(FIRSTNAME,'')+' '+ISNULL(SURNAME,'') AS 'Full Name', IDNUMBER AS 'Employee ID', B.LOCATION AS 'Location', EMPLOYMENT AS 'Employer Name',INDUCTION AS 'Plant Induction', DONOTUSE AS 'Banned From Site',DLEXPIRY AS 'Driving License Expiry' FROM MASTER A, IMERYSCOMPETENCE B WHERE A.STAFFNO = B.STAFFNO AND A.STAFFNO LIKE '%"&Replace(Request.Querystring("staff_number"),"'","''")&"%' ORDER BY SURNAME"
set Conn = server.createobject("ADODB.Connection")
Conn.Open "PROVIDER=SQLOLEDB;" & _
"DATA SOURCE=server;DATABASE=COMPLIANCE;" & _
"USER ID=sa;PASSWORD=password;"
Set RS = Conn.Execute (SQL)
Dim F, Head
For Each F In RS.Fields
Head = Head & ", " & F.Name
Next
Head = Mid(Head,3) & vbCrLf
Response.Addheader "Content-Disposition", "inline; filename=Export.csv"
Response.ContentType = "application/download"
Response.Write Head
Response.Write RS.GetString(,,", ",vbCrLf,"")
Set RS = nothing
Conn.close
%>
|
|
|
|