g3_arun 0 Newbie Poster
<html>
<title>CodeAve.com(Create Excel on Server)</title>
<body bgcolor="#FFFFFF">
<%

accessdb="a" 


cn="DRIVER=Microsoft Access Driver (*.mdb)};"
cn=cn & "DBQ=" & server.mappath(accessdb)

Set rs = Server.CreateObject("ADODB.Recordset")




sql = "select id,empname,phone from empp" 


rs.Open sql,cn

rs.MoveFirst


file_being_created= "states.xls"

set fso = createobject("scripting.filesystemobject")


 
Set act = fso.CreateTextFile(server.mappath(file_being_created), true)


act.WriteLine("<html><body>")
act.WriteLine("<table border=""1"">")
act.WriteLine("<tr>")
act.WriteLine("<th nowrap>id</th>")
act.WriteLine("<th nowrap>empname</th>")
act.WriteLine("<th nowrap>phone</th>")

act.WriteLine("</tr>")


for documents= 1 to 3

Act.WriteLine("<tr>")
act.WriteLine("<td align=""right"">" & rs("id") & "</td>" )
act.WriteLine("<td align=""right"">" & rs("empname") & "</td>" )
act.WriteLine("<td align=""right"">" & rs("phone") & "</td>")

act.WriteLine("</tr>")


rs.movenext

next

act.WriteLine("</table></body></html>")

act.close


response.write "<a href='states.xls'>States</a> (.xls) has been created on " & now() & "<br>"
%>
</body>
</html>

I tryed this code but its shows error like

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
/r.asp, line 20

Please help me

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.