access| data
Suitable for beginners of the reader of ASP a good example article, the specific code is as follows: ( Save the following code as 1.asp)
<%
Response.expires=0
Set conn=server.createobject ("ADODB. Connection ")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Server. MapPath ("Mdb/demo.mdb") & "; mode=readwrite| Share Deny None; Persist Security Info=false "
%>
<HTML>
<HEAD>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<style>
<!--
. p1 {Font-size:9pt}
. L1 {BORDER: #000080 2px Solid}
-->
</style>
</HEAD>
<BODY>
<table cellpadding=0 cellspacing=10 class=l1>
<TR><TD>
<table class=p1>
<%
Dim sql
Dim i
Dim outstr
If Request.ServerVariables ("request_method") = "Get" Then
Sql= "SELECT * from admin"
Set rs=server.createobject ("ADODB. RecordSet ")
Rs. Open sql,conn,3,2
Outstr= "<form Name=forma action=1.asp method=post>"
Outstr=outstr & "<tr><td align=middle> account </td><td align=middle> password </TD></TR> "
For I=1 to 3
If I<=rs. RecordCount Then
Outstr=outstr & "<tr><td><input class=p1 name=t1" & I & "Size=20 value=" & Chr (+) & R S ("account") & Chr (+) & "></td><td><input class=p1 name=t2" & I & "size=20 value=" & Ch R (+) & RS ("password") & Chr (+) & "></TD></TR>"
Rs. MoveNext
Else
Outstr=outstr & "<tr><td><input class=p1 name=t1" & I & "size=20></td><td> <input class=p1 name=t2 "& I &" Size=20></td></tr> "
End If
Next
Response.Write (OUTSTR)
%>
<TR><TD align=middle colspan=2><a href= "Javascript:document.forma.submit ();" > Modify Data </A></TD></TR>
<%
Conn.close
Set conn=nothing
Else
Set Rs=conn.execute ("Delete * from admin")
For I=1 to 3
Sql= "INSERT into admin (account number, password) VALUES ('" & Request.Form ("T1" & i) & "', '" & Request.Form ("T2" & i) &am P "')"
Set rs=conn.execute (SQL)
Next
%>
<TR><TD Align=middle class=p5> Modify operation successfully <br><br><a href= "1.asp" > Display data </a></td ></TR>
<%
Conn.close
Set conn=nothing
End If
%>
</TABLE>
</TD></TR></TABLE>
</BODY>
</HTML>
Finally to provide you with the article used in the database: Click here to download the database file ( Note: The download database file renamed to demo.mdb into the MDB directory )