ASP Access Insert Update Delete use

Source: Internet
Author: User

This tutorial is an introductory tutorial for ASP access, which is mainly about the simple use of ASP, insert Update Delete Oh, OK. Let's write them down in a function and then give an example.

Function add_del_update (tablename,str,id)
Select Case str
 case "Insert":
   sql= "Select * FROM [&tablename&] where id=null "
   rs.open sql,conn,1,3
   rs.addnew
   for each key in request. Form
     Response.Write "RS (" &cstr (Key) & ") =" &request (key) & "<br>"
      RS (CStr (key)) =request (key)
   Next
   rs.update
& nbsp;  rs.close
 case "Update":  
   sql= "select * FROM [" &tablename& "] where id= "&id
   rs.open sql,conn,1,3 
   for each key in request. Form
      if key<> "id" then
        rs ( CSTR (Key) =request (key)
      End If
   Next
   rs.update
   rs.close
 case "Delete":  
   sql= "Delete from [&tablename&"] where ID in ("&id&") "
   Rs.Open sql,conn,1,3
 case "
 end Select
 end Function
%>

<%
  Add a record to the Table1 table
 call add_del_update ("table1", "Insert", ")
Modify table1 in the id=5 table ( The ID is placed in the previous page action, or it can be a hidden form) record   
  id=request ("id")
  call Add_del_update ("table1", "Update , ID
Delete some records from the Table1 table, either the previous page action, or a form
  id=request ("id")
  call Add_del_update ("table1" , "delete", id)
%>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.