ASP Access Insert Update Delete use

Source: Internet
Author: User

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
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" ("&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 the id=5 in the Table1 table (ID is placed in the previous page action, or it can be a hidden form)
' Id=request ("id")
' Call Add_del_update ("table1", "update", ID)
' Delete some records in the Table1 table, the ID is in the previous page action, or it can be 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.