User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP section within the Web Development category of DaniWeb, a massive community of 422,420 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 5,222 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP advertiser: Lunarpages ASP Web Hosting
Views: 603 | Replies: 0
Reply
Join Date: Jun 2008
Posts: 1
Reputation: g3_arun is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
g3_arun g3_arun is offline Offline
Newbie Poster

how to code for retrive data from sql server 2003 to excel sheet by using asp

  #1  
Jun 2nd, 2008
  1. <html>
  2. <title>CodeAve.com(Create Excel on Server)</title>
  3. <body bgcolor="#FFFFFF">
  4. <%
  5.  
  6. accessdb="a"
  7.  
  8.  
  9. cn="DRIVER=Microsoft Access Driver (*.mdb)};"
  10. cn=cn & "DBQ=" & server.mappath(accessdb)
  11.  
  12. Set rs = Server.CreateObject("ADODB.Recordset")
  13.  
  14.  
  15.  
  16.  
  17. sql = "select id,empname,phone from empp"
  18.  
  19.  
  20. rs.Open sql,cn
  21.  
  22. rs.MoveFirst
  23.  
  24.  
  25. file_being_created= "states.xls"
  26.  
  27. set fso = createobject("scripting.filesystemobject")
  28.  
  29.  
  30.  
  31. Set act = fso.CreateTextFile(server.mappath(file_being_created), true)
  32.  
  33.  
  34. act.WriteLine("<html><body>")
  35. act.WriteLine("<table border=""1"">")
  36. act.WriteLine("<tr>")
  37. act.WriteLine("<th nowrap>id</th>")
  38. act.WriteLine("<th nowrap>empname</th>")
  39. act.WriteLine("<th nowrap>phone</th>")
  40.  
  41. act.WriteLine("</tr>")
  42.  
  43.  
  44. for documents= 1 to 3
  45.  
  46. Act.WriteLine("<tr>")
  47. act.WriteLine("<td align=""right"">" & rs("id") & "</td>" )
  48. act.WriteLine("<td align=""right"">" & rs("empname") & "</td>" )
  49. act.WriteLine("<td align=""right"">" & rs("phone") & "</td>")
  50.  
  51. act.WriteLine("</tr>")
  52.  
  53.  
  54. rs.movenext
  55.  
  56. next
  57.  
  58. act.WriteLine("</table></body></html>")
  59.  
  60. act.close
  61.  
  62.  
  63. response.write "<a href='states.xls'>States</a> (.xls) has been created on " & now() & "<br>"
  64. %>
  65. </body>
  66. </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
Last edited by peter_budo : Jun 4th, 2008 at 3:26 am. Reason: Keep It Organized - please use [code] tags
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the ASP Forum

All times are GMT -4. The time now is 9:40 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC