How does ADO add changes to the record of deleting a database?

Source: Internet
Author: User
Tags access database
Records of new databases
First use ADO to connect to the Access database Ntopsamp.mdb, open the table "product" record with SQL instruction, and pass the result back to Rs1 's
In the recordset, the ASP code is as follows:
Set conn1 = Server.CreateObject ("ADODB. Connection ")
Conn1. Open "dbq=" & Server.MapPath ("Ntopsamp.mdb") & ";D river={microsoft Access Driver (*.mdb)};"
Set rs1 = Server.CreateObject ("ADODB. Recordset ")
Rs1. Open "Products", conn1,1,3
Using the AddNew method to add a record, the ASP code is as follows:
Rs1. Addnew
Set the values for each field in the record table, you can use the following three syntax:
Rs1 ("field name"). Value = values
Rs1 ("field name") = value
Rs1 (field order) = value
For example, ASP code is as follows:
Rs1 ("name"). Value = "Note-taking computer"
Rs1 ("quantity") = 100
Rs1 (0) = "12345"
The next Update method is to store the new records in the table.
Rs1. Update
Rs1. Close
Response.Write ("add record: Name = notebook computer")
")
Modify the records of a database
To modify the records of the database, first use ADO to link to the Access database Ntopsamp.mdb, the next SQL instruction to find the record to be modified, will knot
The results are returned to Rs1 's Recordset, and the ASP code is as follows:
Set rs1 = Server.CreateObject ("ADODB. Recordset ")
sql = "SELECT * FROM product WHERE name = ' Note-PC '"
Rs1. Open sql,conn1,1,3
If you find the record to be modified, set the value of each field in the table, the last Update method, the new record will be stored in the table, ASP code
As follows:
If not rs1. EOF Then
Randomize
No1 = Round (Rnd () * 10)
New1 = "Notebook Computer-" & No1
Rs1 ("name"). Value = New1
Rs1. Update
Response.Write ("Modify record: Name =" & Rs1 ("name") & "")
End If
Deleting records from a database
To remove records from a database, first use ADO to link to an Access database Ntopsamp.mdb, the next SQL instruction looks for records to be deleted, and returns the results back to the RS1 Recordset with ASP code as follows:
Set rs1 = Server.CreateObject ("ADODB. Recordset ")
sql = "SELECT * FROM product WHERE name = '" & New1 & "'"
Rs1. Open sql,conn1,1,3
If you find the record you want to delete, the next Delete method, you can delete the record in the table, and the ASP code is as follows:
If not rs1. EOF Then
Rs1. Delete
Response.Write ("Delete record: Name =" & New1)
End If
Conn1. Close

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.