home *** CD-ROM | disk | FTP | other *** search
/ Chip 2009 November / Chip_2009.11_CD.iso / I386 / IIS6.CAB / IIS_AddDelete_VBScript.asp < prev    next >
Encoding:
Text File  |  2001-10-04  |  1.6 KB  |  60 lines

  1. <%@ LANGUAGE = VBScript %>
  2. <%  Option Explicit %>
  3. <%  Response.Expires= -1 %>
  4.  
  5. <!--METADATA TYPE="typelib" 
  6. uuid="00000206-0000-0010-8000-00AA006D2EA4" -->
  7.  
  8. <HTML>
  9.     <HEAD>
  10.         <TITLE>Add/Delete Database Sample</TITLE>
  11.     </HEAD>
  12.  
  13.     <BODY BGCOLOR="White" topmargin="10" leftmargin="10">
  14.  
  15.         <!-- Display Header -->
  16.  
  17.         <font size="4" face="Arial, Helvetica">
  18.         <b>Add/Delete Database Sample</b></font><br>
  19.       
  20.         <hr size="1" color="#000000">
  21.  
  22.         <%
  23.             Dim oConn        
  24.             Dim oRs            
  25.             Dim filePath        
  26.  
  27.             
  28.             ' Map authors database to physical path
  29.             filePath = Server.MapPath("authors.mdb")
  30.  
  31.  
  32.             ' Create ADO Connection Component to connect with sample database
  33.             
  34.  
  35.             
  36.             Set oConn = Server.CreateObject("ADODB.Connection")
  37.             oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & filePath
  38.  
  39.             ' To add, delete and update  recordset, it is recommended to use 
  40.             ' direct SQL statement instead of ADO methods.
  41.             
  42.             oConn.Execute "insert into authors (author, YearBorn) values ('Paul Enfield', 1967)"
  43.             
  44.             ' Output Result
  45.             Set oRs = oConn.Execute (" select * from authors where Author= 'Paul Enfield' and YearBorn =1967 " )
  46.             Response.Write("<p>Inserted Author: " & oRs("Author") & "," & oRs("YearBorn"))
  47.             ' Close Recordset
  48.             oRs.Close
  49.             Set oRs= Nothing
  50.             
  51.             
  52.             ' Delete the inserted record
  53.             oConn.Execute "Delete From authors where  author='Paul Enfield' and YearBorn = 1967 "
  54.             
  55.             ' Output Status Result
  56.             Response.Write("<p>Deleted Author: Paul Enfield, 1967")
  57.         %>
  58.     </BODY>
  59. </HTML>
  60.