Asp+ado to implement a simple example of data reading and writing

Source: Internet
Author: User
Tags add implement
ado|asp+| Example | data |ado| sample//showdata.asp
<%@ language= "VBScript" codepage= "936"%>

<title>[show the Data]</title>

<body>
<%
Application.Lock ()
Set dataconnect = Server.CreateObject ("ADODB. Connection ")
strconnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
&server.mappath ("Db1.mdb") &_
"; Persist Security Info=true "
Dataconnect.open (StrConnect)
If Request.Form ("name") <> "" or Request.Form ("phone") then
Sqlinsertcmd = "INSERT INTO table1 (name,phone) VALUES ('" _
&request.form ("name") & "', '" &request.form ("Phone") & "')"
Dataconnect.execute (Sqlinsertcmd)
End If
Set dbtabptr = Server.CreateObject ("ADODB. Recordset ")
Dbtabptr. ActiveConnection = Dataconnect
strSQL = "SELECT * FROM table1"
Dbtabptr. Open (strSQL)
Response.Write ("<table width= ' 100% ' border= ' 1 ' >")
Response.Write ("<tr>")
Response.Write ("<th>name</th>")
Response.Write ("<th>phone</th>")
Dbtabptr. MoveFirst ()
Do until dbtabptr. Eof
Response.Write ("<tr>")
Response.Write ("<td>")
Response.Write (Dbtabptr ("name"))
Response.Write ("</td>")
Response.Write ("<td>")
Response.Write (Dbtabptr ("Phone"))
Response.Write ("</td>")
Response.Write ("</tr>")
Dbtabptr. MoveNext ()
Loop
Response.Write ("</tr>")
Response.Write ("</table>")
Dataconnect.close ()
Application.UnLock ()
%>
<a href= "adddata.asp" >add a Data to database</a>
</body>
Adddata.asp
<%@ language= "VBScript" codepage= "936"%>
<title>[add data]</title>
<body>
<form name= "AddData" action= "showdata.asp" method= "POST" >
<table>
<tr>
&LT;TD align= "right" >name:</td>
<td><input name= "name" type= "text"/></td>
</tr>
<tr>



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.