ASP Direct Read Demo instance that modifies access data

Source: Internet
Author: User
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)
%>
&LT;TR&GT;&LT;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
%>
&LT;TR&GT;&LT;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 )



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.