ADO API Reference (Parameter Object & Property Object & Recordset Object)

zhaozj2021-02-17  49

Parameter object

Parameter object represents parameters or arguments associated with a Command object based on parameterized query or stored procedures.

Description

Many providers support parameterized commands. The operations that need to be performed are only defined in these commands, but some details of the command can be changed using variables (or parameters). For example, the SQL SELECT statement can use the parameter to define the matching condition of the WHERE clause, and use another parameter to define the name of the column of the Sort By clause.

Parameter object represents the parameters associated with the parameterized query, or the return / output parameter and the return value of the stored procedure. Depending on the functionality of the provider, some sets, methods, or attributes of the Parameter object may be invalid.

Use the collection, method, and properties of the Parameter object to do the following:

Use the NAME property to set or return to the parameter name. Use the Value property to set or return to the parameter value. Use Attributes and Direction, Precision, NuMERICScale, Size, and Type properties to set or return parameter feature. Use the Appendchunk method to pass long binary or character data to the parameter.

If you know the parameter properties and names associated with the stored procedure or parameterized query you want to call, you can use the CreateParameter method to create a Parameter object with the corresponding property settings and use the Append method to add them to the Parameters collection. This can be set and returned to the parameter value without calling the parameter information of the Parameters collection to retrieve the provider's parameter information, the operations in the resource set.

Property object

The Property object represents the dynamic feature of the ADO object defined by the provider.

Description

ADO objects have two types of properties: built-in properties and dynamic properties.

Built-in attributes are implemented in ADO and immediately use the properties of any new object, at which time use myObject.property syntax. They don't appear as the Property object in the object's Properties collection, so although their values ​​can be changed, their feature cannot be changed.

Dynamic properties are defined by basic data providers and appear in the Properties collection of the corresponding ADO object. For example, specifying an attribute that may indicate whether the Recordset object supports transaction or update. These additional properties will appear as a Property object in the Properties collection of the Recordset object. Dynamic properties can only be referenced by using myObject.properties (0) or myObject.properties ("name") syntax by collection.

Both attributes cannot be deleted.

Dynamic Property object has four own built-in properties:

The Name property is a string that identifies attributes. The Type property is an integer for specifying the type of properties data. The value attribute is a variant type containing the property setting. Attributes property is a long integer value indicating the provider's attribute feature.

Recordset object

The Recordset object represents a complete collection of records from the basic table or command execution result. At any time, the current record referred to by the RecordSet object is a single record within the collection.

Description

You can use the RecordSet object to operate data from the provider. When using ADO, almost all data can be operated via the Recordset object. All RecordSet objects are constructed using records (rows) and fields (columns). Some RecordSet methods or properties may be invalid because the features supported by the provider.

Ador.Recordset and AdoDB.Recordset are progids used to create Recordset objects. The resulting Recordset object behavior is the same, regardless of ProgID. Ador.Recordset installed with Microsoft® Internet Explorer, and AdoDb.Recordset installed with ADO. The behavior of the Recordset object is affected by the environment (ie client, server, Internet Explorer et al.). These differences will be described in the "Help" topic of attributes, methods, and events. Four different cursor types are defined in ADO:

Dynamic Cursor - Used to see addition, change, and delete other users, and use to move in all types of mobile non-replacement. If the provider supports, you can use a bookmark. Key set cursor - its behavior is similar to dynamic cursor, and different is only to see the records added by other users, and disable access to other users' deletions, and the data changes made by other users will remain visible. It always supports bookmarks, thus allowing various types of movements in RecordSet. Static Cursor - Provides a static copy of the record collection to find data or generate a report. It always supports bookmarks, thus allowing various types of movements in RecordSet. The addition, changes, or deletion made by other users will be invisible. This is the only cursor type that allows usage when opening the client (Ador) Recordset object. Only the forward cursor - except only allowed to scroll forward in the record, its behavior is similar to a static cursor. This way, performance can be improved when moving one-way movement in the Recordset.

Set the CURSORTYPE attribute before opening Recordset to select the cursor type, or use the Open method to pass the CURSORTYPE parameter. Some providers do not support all cursor types. Check the provider's documentation. If you do not specify a cursor type, ADO will open only the forward cursor by default.

If the CursorLocation property is set to AduseClient, open the Recordset, in the returned RecordSet object, the underlyingValue property of the Field object is not available. For partial providers (such as Microsoft ODBC Provider for Ole DB, with Microsoft SQL Server), you can create a Recordset object independently based on the previously defined Connection object by using the Open method. ADO still creates a Connection object, but it does not assign the object to the object variable. However, if multiple RecordSet objects are being opened on the same connection, you should explicitly create and open the Connection object, thereby assigning the Connection object to the object variable. If this object variable is not used when the Recordset object is opened, the ADO will create a new Connection object for each new Recordset even if the same connection string is delivered.

You can create the required number of Recordset objects.

When you open the Recordset, the current record is located in the first record (if any), and the BOF and EOF properties are set to false. If there is no record, the BOF and EOF property settings are true.

Suppose the provider supports the relevant features, you can use the MoveFirst, MoveLast, MoveNext, and the MovePrevious method, and the Move method, and the AbsolutePosition, the AbsolutePage, and the Filter property re-determines the location of the current record. The MoveNext method is only supported only with a forward Recordset object. When accessing each record (or enumerated RECORDSET) using the MOVE method, you can use the BOF and EOF properties to see if the movement has exceeded the beginning or end of the Recordset. The Recordset object supports two types of updates: updates and batch updates now. Using the update now, once the Update method is called, all changes to the data will be immediately written to the basic data source. You can also use the addNew and UPDATE methods to pass values ​​as parameter, and update several fields of records.

If the provider supports batch updates, allows the provider to store multiple records to the cache, and then transfer them to the database in a single call using the UpdateBatch method. This situation is applied to the changes made using AddNew, Update, and Delete methods. Once the UpdateBatch method is called, you can use the Status property to check any data conflicts and resolve.

Note To perform a query that does not use the Command object, the query string should be passed to the OPEN method for the Recordset object. However, the Command object is still needed when you want to keep the command text and repeat or use the query parameter.

转载请注明原文地址:https://www.9cbs.com/read-29979.html

New Post(0)