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)
%>