home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / iis4_07.cab / SimpleQuery_VBScript.asp < prev    next >
Text File  |  1997-10-25  |  1KB  |  70 lines

  1. <%@ LANGUAGE = VBScript %>
  2. <%  Option Explicit        %>
  3.  
  4. <HTML>
  5.     <HEAD>
  6.         <TITLE>Simple ADO Query</TITLE>
  7.     </HEAD>
  8.  
  9.     <BODY BGCOLOR="White" topmargin="10" leftmargin="10">
  10.  
  11.         <!-- Display Header -->
  12.  
  13.         <font size="4" face="Arial, Helvetica">
  14.         <b>Simple ADO Query with ASP</b></font><br>
  15.     
  16.         <hr size="1" color="#000000">
  17.  
  18.         Contacts within the Authors Database:<br><br>
  19.  
  20.         <%
  21.             Dim oConn        
  22.             Dim oRs        
  23.             Dim curDir        
  24.             Dim Index        
  25.  
  26.             
  27.             ' Map authors database to physical path
  28.             curDir = Server.MapPath("\iissamples\sdk\asp\database\authors.mdb")
  29.  
  30.  
  31.             ' Create ADO Connection Component to connect
  32.             ' with sample database
  33.             
  34.             Set oConn = Server.CreateObject("ADODB.Connection")
  35.             oConn.Open "DBQ="& curDir &";Driver={Microsoft Access Driver (*.mdb)};DriverId=25;FIL=MS Access;"
  36.             
  37.             
  38.             ' Execute a SQL query and store the results
  39.             ' within recordset
  40.             
  41.             Set oRs = oConn.Execute("SELECT * From authors")
  42.         %>
  43.  
  44.  
  45.         <TABLE border = 1>
  46.         <%  
  47.             Do while (Not oRs.eof) %>
  48.  
  49.                 <tr>
  50.                     <% For Index=0 to (oRs.fields.count-1) %>
  51.                         <TD VAlign=top><% = oRs(Index)%></TD>
  52.                     <% Next %>
  53.                 </tr>
  54.             
  55.                 <% oRs.MoveNext 
  56.             Loop 
  57.         %>
  58.  
  59.  
  60.         </TABLE>
  61.  
  62.  
  63.         <%   
  64.             oRs.close
  65.             oConn.close 
  66.         %>
  67.  
  68.     </BODY>
  69. </HTML>
  70.