home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 25: Programming / pc_actual_25.iso / Javascript / InteractiveWebDesignJavascript / Scripting / cgi1 / scripting / asp / Database_demo.asp < prev    next >
Encoding:
Text File  |  2001-07-18  |  1.4 KB  |  56 lines

  1. <html>
  2.  
  3. <head>
  4. <meta name="GENERATOR" content="Microsoft FrontPage 3.0">
  5. <title>Northwind DataBase Demo</title>
  6.  
  7. <meta name="Microsoft Theme" content="none, default">
  8. </head>
  9.  
  10. <body>
  11.  
  12. <h1>Northwind Employee Roster</h1>
  13.  
  14. <p><big>The following list is generated dynamically using an ASP script which queries an
  15. ODBC database. </big></p>
  16. <!-- start the table to wrap around the data -->
  17. <div align="center"><center>
  18.  
  19. <table border="1">
  20. <%
  21. 'Create a connection object
  22.   Set cn = Server.CreateObject("ADODB.Connection")
  23.  
  24. 'Open a connection; the string refers to the DSN
  25.   cn.Open  "FILEDSN=My_Development_DB.dsn"
  26.  
  27. 'Instantiate a Recordset object 
  28.     Set rsCustomers = Server.CreateObject("ADODB.Recordset") 
  29.  
  30. 'Open a recordset using the Open method 
  31. ' and use the connection established by the Connection object 
  32.     strSQL = "SELECT * FROM Employees" 
  33.     rsCustomers.Open strSQL, cn 
  34.  
  35. 'Cycle through record set and display the results 
  36. ' and increment record position with MoveNext method 
  37.     Set objFirstName = rsCustomers("FirstName") 
  38.     Set objLastName = rsCustomers("LastName") 
  39.  
  40.     Do Until rsCustomers.EOF 
  41.         Response.Write "<tr><td bgcolor='#C0C0C0'>"
  42.         Response.Write objFirstName & " " & objLastName & "</td></tr>" 
  43.         rsCustomers.MoveNext 
  44.     Loop
  45.  
  46. 'Close the DB connection
  47.     cn.Close
  48.  
  49. %>
  50. </table>
  51. </center></div>
  52.  
  53. <p><big>Note that adding the HTML to display the results is the programmers responsibility</big></p>
  54. </body>
  55. </html>
  56.