Basic Object of asp ado Model

Source: Internet
Author: User

Ado model Summary
Microsoft's ActiveX Data Objects (ADO) is a COM component used to access data sources. It providesProgramming LanguageAnd an intermediate layer of the Unified Data Access Method ole db. Allows developers to write and access dataCodeInstead of worrying about how the database is implemented, we only need to care about the database connection. When accessing a database, the knowledge about SQL is not necessary, but the SQL commands supported by a specific database can still be executed through the command objects in ADO.
Ado contains some top-level objects:

Connection, indicating the connection to the database
Recordset, which represents a set of database records
Command, representing an SQL command
Record, representing a set of data
Flow, representing the sequence set of data
Error indicates an error occurred during database access.
Field, representing a database Field
Paramer, representing an SQL Parameter
Porperties: stores object information.

I. Connection
// Provide the connection to the database. The other two objects are used to complete database operations.

Set Cn = server. Createobject ("ADODB. Connection ")
CN. Open "driver = {ODBC driverProgram}; DBQ = database name"

Function & Properties
Open: open a connection object instance // CN. Open connectionstring
Execute: generate A recordset instance (you do not need to instantiate the recordset object separately)
// CN. Execute commandtext
1. SQL statement, indicating that a SQL statement will be executed
2. A table name of the database, indicating that the table will be operated
* Tip: A recordset object will be instantiated in actual situations for greater flexibility.
Ex.
<%
Set conn = server. createobejct ("ADODB. Connection ")
Conn. Open "drive = {Microsoft Access Driver (*. mdb)}; DBQ =" & server. mappath ("Data/data. mdb ")
Set rs = server. createobejct ("ADODB. recordset ")
Rs = conn. Execute ("select * from user") <-! Grant the information returned by the query to the RS object->
<-! Rs. Open "select * from user", Conn, have the same function as the previous command->
%>

Ii. recordset
// Indicates the complete set of records from table-based or command execution results

Set rs = server. createobjecct ("ADODB. recordset ")
Rs. Open Table | SQL command, connection, record type, locked type
Record type
1. move the cursor downward.
2. move the cursor up
Locked type
1. read-only data
2. synchronous update allowed
3. Record updates. The table is not updated.

Function & Properties

Open
Close: Close the connection to the recordset object
Movefirst: Move the pointer to the beginning of the table.
Movelast: Move the pointer to the end of the table
Movenext: Move the pointer down a row
Movepervious: Move the pointer up a row

Paging:
Absolutepage: The current absolute data page location <-! The page on which the current record belongs->
Bof: BOF at the beginning of the dataset (type = Boolean) <-! Above the first record->
EOF: End boundary of the Data Group (type = Boolean) <! Below->
Pagecount: Total number of data pages
Pagesize: controls the number of records on each data page.
Recordcount: Total number of records retrieved by the server

 

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.