ADO in the "Ten Days Learn ASP" tutorial, I rough introduced a bit ADO, in fact, can be said to be. It's just that the open method in the Connection object establishes a physical connection to the data source and disconnects it using the Close method; The changes made using the AddNew, Update, and Delete methods in the Recordset object refer to the AbsolutePage and RecordCount properties in the Recordset object in the final page. Here I think it is necessary to more than the system of ADO about the various objects of the methods, attributes. After all, ADO is not only used in ASP, VB,VC can be used. In these 10 days, I would like to refer mainly to the following subjects:
Connection object (represents an open connection to a data source.) )
A Recordset object representing the complete collection of records from a basic table or command execution result. )
The Parameter objects and command objects that are closely related to the stored procedure are described in detail in a later tutorial.
Let's take a look at the Connection object method:
1. Open method
Connection. Open ConnectionString, UserID, Password, Options
ConnectionString Optional, string, containing connection information.
UserID Optional, string containing the user name to use when establishing the connection.
Password Optional, string containing the password to use when establishing the connection.
Options optional, ConnectOptionEnum value. Determines whether the method returns after the connection is established (asynchronously) or before the connection is established (synchronous). Can be one of the following constants:
Adconnectunspecified (default) to open the connection synchronously.
Adasyncconnect Open the connection asynchronously.
2. Execute method
Connection. Execute CommandText, RecordsAffected
CommandText string that contains the text of the SQL statement, table name, stored procedure, or specific provider to execute.
RecordsAffected optional, long integer variable, the number of records affected by the provider returning operations to it.
3. Close method
Connection. Close
Use the Close method to turn off the Connection object to free all associated system resources.
It is to be noted that:
(1) Closing an object does not remove it from memory, you can change its property settings and open it again after that.
(2) To completely remove an object from memory, set the object variable to nothing.
(3) Closing the Connection object with the Close method also closes any active Recordset objects associated with the connection.
(4) When you close the Connection object, calling any method that needs to be opened to connect to the data source will produce an error.
All three of these methods should be well known.
Here's a quick look at the properties of the Connection object.
1, Provider property
Specify the OLE DB provider by using the Provider property.
Note that specifying a provider in multiple places when you invoke the Open method can have unpredictable consequences.
2, ConnectionString Property
Contains information that is used to establish a connection data source.
3, ConnectionTimeout property
Indicates the length of time, in seconds, that waits during a connection before terminating the attempt and generating an error, waiting for the connection to open. The default value is 15.
4, Mode Properties
Indicates the available permissions to modify data in Connection.
Constants Description
adModeUnknown default value. Indicates that the permission has not been set or cannot be determined.
adModeRead indicates that the permission is read-only.
adModeWrite indicates that the permission is write-only.
adModeReadWrite indicates that the permission is read/write.
adModeShareDenyRead prevents other users from opening the connection with Read permissions.
adModeShareDenyWrite prevents other users from opening the connection with write permission.
Admodeshareexclusive prevents other users from opening the connection.
adModeShareDenyNone prevents other users from opening the connection with any permissions.
It is to be noted that:
Use the Mode property to set or return the access rights that the provider is using on the current connection. The Mode property can be set only when the Connection object is closed.
Today, let's talk about the properties of the Recordset object tomorrow.