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

  1. <%@ LANGUAGE = JScript %>
  2.  
  3. <HTML>
  4.     <HEAD>
  5.         <TITLE>Simple ADO Query</TITLE>
  6.     </HEAD>
  7.  
  8.     <BODY BGCOLOR="White" topmargin="10" leftmargin="10">
  9.  
  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.             var oConn;        
  22.             var oRs;        
  23.             var curDir;        
  24.  
  25.             
  26.             // Map authors database to physical path
  27.             
  28.             curDir = Server.MapPath("\\iissamples\\sdk\\asp\\database\\authors.mdb");
  29.  
  30.  
  31.             // Create ADO Connection Component to connect with
  32.             // sample database
  33.             
  34.             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 within
  39.             // recordset
  40.             
  41.             oRs = oConn.Execute("SELECT * From authors");
  42.         %>
  43.  
  44.  
  45.         <TABLE border = 1>
  46.         <%  
  47.             while (!oRs.eof) { %>
  48.  
  49.                 <tr>
  50.                     <% for(Index=0; Index < (oRs.fields.count); Index++) { %>
  51.                         <TD VAlign=top><% = oRs(Index)%></TD>
  52.                     <% } %>
  53.                 </tr>
  54.             
  55.                 <% oRs.MoveNext();
  56.             } 
  57.         %>
  58.  
  59.         </TABLE>
  60.  
  61.  
  62.         <%   
  63.             oRs.close();
  64.             oConn.close();
  65.         %>
  66.  
  67.     </BODY>
  68. </HTML>
  69.