One of the ADO API Reference (ADO)

zhaozj2021-02-17  55

AddNew method

Create a new record that updates the Recordset object.

grammar

Recordset.addnew Fieldlist, Values

parameter

FieldList is optional. A single name, a set of names or serial numbers in the new record.

VALUES is optional. A single or set value of the field in the new record. If Fields is an array, Values ​​must also have an array with the same number of members, otherwise an error will occur. The order of the field name must match the order of the field values ​​in each array.

Description

Create and initialize new records using the AddNew method. Using the AdAddNew Use the Supports method to verify that the record can be added to the current Recordset object.

After calling the AddNew method, the new record will be the current record and continue to remain currently recorded after calling the UPDATE method. If the Recordset object does not support bookmarks, new records will not be accessed when moving to other records. Whether you need to call the Requery method Access new record depends on the type of cursor used.

If you call AddNew when editing the current record or add a new record, ADO will call any changes and create a new record.

The act of the AddNew method depends on the update mode of the Recordset object and whether the fields and values ​​parameters are transmitted.

Under the Immediate Update Mode (Call the Update method, the provider will immediately write the change to the basic data source), call the addNew method without the parameters to set the EditMode property to ADEDITADD. The provider is locally locally in a change in any field value. Call the UPDATE method to pass the new record to the database and reset the EditMode property to AdEDitnone. If the fields and values ​​parameters are transmitted, the ADO immediately passes the new record to the database (no need to call Update), and the EditMode property value has no change (AdedNone).

In the batch update mode (provider cache multiple changes and writes it to the basic data source only when calling UpdateBatch), call the addNew method without parameters to set the EditMode property to ADEDITADD. The provider is locally locally in a change in any field value. Call the Update method Add a new record to the current recordset and reset the EditMode property to AdEDitnone, but the provider does not pass the change to the basic database before calling the UpdateBatch method. If the Fields and VALUES parameters are transmitted, the ADO sends a new record to the provider to cache; if you need to call the UpdateBatch method to pass the new record to the basic database.

If the Unique Table dynamic property is set, and the Recordset is the result of performing the JOIN operation for multiple tables, then the AddNew method can only insert the field into the table named by the UNIQUE TABLE property.

Append method

Add an object to a collection. If the collection is Fields, you can create a new Field object and then add it to the collection.

grammar

Collection.Append Object

Fields.Append Name, Type, DefinedSize, Attrib

parameter

Collection set object.

Fields fields collection.

Object object variables represent the object you want to add.

Name string, the name of the new field object, may not be the same name with any other object in Fields.

Type DataTyPeenum type, its default value is ademption. The data type of the new field.

DefinedSize optional, long integer, indicating the definition size of the new field (in characters or bytes). The default value of this parameter is derived from Type (the default Type is Ademption, the default definedSize is not specified). Attrib Optional, FieldAttributeEnum, its default value is AdfldDefault. Specify the properties of the new field. If this value is not specified, the field will contain the properties derived from Type.

parameter

Using the APPEND method on a collection to add objects to this collection, this method is only valid on the parameters collection of the Command object. It is necessary to set its Type property before adding the Parameter object to the Parameters collection. If you select the beat length data type, you must set the size property to a value greater than zero.

By making a description of the parameters, the call to the provider can minimize the performance of the provider, thereby improving performance while using a stored procedure or parameterized query, but must be understood to be a parameter property associated with the stored procedure or parameterized query to be called. Using the CreateParameter method, you can create a parameter object with the appropriate property settings, while using the Append method, you can add them to the parameters collection. This allows you to set and return parameter values ​​without calling the provider of parameter information. If you write to the provider that does not provide parameter information, you must use the method to manually fill in the parameters collection so that the parameters can be fully used.

Field

If you do not set the CursorLocation property before calling the fields.append method, CursorLocation will be automatically set to aduseclient when using the Open method to open Recordset.

Touching its fields.Append method to raise runtime errors to call their fields.Append method to call its field. You can only append the field to the RECORDSET that is not open and has not been connected to the data source. Generally, through the CreateRecordset method or by explicitly assigning the new Recordset object to the object variable, all new Recordset objects.

Appendchunk method

Add data to large text, binary data field or parameter object.

grammar

Object.Appendchunk Data

parameter

Object Field or Parameter object

Data variants, including data added to the object.

Description

The Appendchunk method using the field or parameter object can be filled in the object in the object. In the case where the system is limited, the Appendchunk method can be used to partially perform a portion rather than all operations.

Field

If the Adfldlong bit in the Field object Attributes property is set to true, you can use the Appendchunk method to this field.

The first Appendchunk call on the field object writes the data to the field, overrides any existing data, and subsequent AppendChunk calls are added to existing data. If the data is added to a field, then set or read the value of the other field in the current record, the ADO believes that the data has been added to the first field. If the AppendChunk method is called again on the first field, the ADO will call the new Appendchunk operation and overwrite existing data. Visiting the fields in other Recordset objects (not the first RecordSet object) will not undermine the AppendChunk operation.

If there is no current record when calling the Field object, an error will occur.

parameter

If the Adfldlong bit in the Parameter object Attributes property is set to true, this parameter can be used using the Appendchunk method. The first Appendchunk call on the Parameter object writes the data to the parameter, overrides any existing data, and the AppendChunk call on the Parameter object can be added to the existing parameter data. Appendchunk calls that deliver null values ​​are discarded all parameter data.

BeGintrans, CommitTrans and RollbackTrans Methods

These transaction methods manages the transaction process in the Connection object as follows:

Begintrans - Start a new transaction. CommitTrans - Save any changes and end current transactions. It may also start new transactions. RollbackTrans - Cancel any changes made in the current transaction and end transactions. It may also start new transactions.

grammar

Level = Object.begintrans ()

Object.beggintrans

Object.committrans

Object.rollbacktrans

return value

BeGintrans can be called as a function to return a long-integrated variable indicative of the transaction nested level.

parameter

Object Connection object.

Connection

Use these CONNECTION objects that have a Connection object if you want to save or cancel the source data with a stand-alone unit. For example, when currency transfer, you must subtract some amount from the account and add it to another account. No matter which update fails, the account balance will be imbalanced. These changes are made in the open transaction ensures that all changes can only be made or do not make any changes.

Note Not all providers support transactions. Required Verify that the provider defined attribute "Transaction DDL" appears in the Properties collection of the Connection object, if the provider supports transactions. If the provider does not support transactions, call a certain method will return an error.

Once the Begintrans method is called, the provider will no longer submit any changes to the Office immediately before calling the CommItTrans or RollBackTrans ending.

For providers who support nested transactions, the BeGintrans method that is opened in the transaction will begin new nested transactions. The return value will indicate the nested level: the return value is 1 indicates that the top-level transaction has been opened (ie, the transaction is not nested by another business), and the return value is 2 indicates that the second layer transaction has been opened (nesting in top-level transaction ),And so on. Calling CommitTrans or RollBackTrans only affects the latest open transactions; must turn off or back to current transactions before processing any higher-level transactions.

Call the CommitTrans method to save the changes made in the transaction on the connection and end the transaction. Call the RollBackTrans method to restore the changes made in the transaction and end the transaction. Calling it will trigger an error while the transaction is not turned on.

Depending on the Attributes property of the Connection object, call the committrans or rollbackTrans methods to automatically start a new transaction. If the Attributes property is set to AdxactCommitretaining, the provider will automatically start a new transaction after the CommitTrans call. If the Attributes property is set to Adxactabortretaining, the provider will automatically start a new transaction after calling RollbackTrans.

Remote data service

BeGintrans, CommitTrans and RollbackTrans methods are invalid on the client Connection object.

CreateObject Method (RDS)

Create a proxy for the target business object and return to the pointer to it. The agent packs the data and dispatches to the server-side communication module to communicate with the business object to send requests and data over the Internet. For components objects within the process, do not use the agent, but only the pointer to the object. grammar

Remote Data Services supports the following protocols: HTTP, HTTPS (through the HTTP of the security socket layer), DCOM, and processes.

Protocol syntax HTTPSet object = DataSpace.CreateObject ( "ProgId", "http: // awebsrvr") HTTPSSet object = DataSpace.CreateObject ( "ProgId", "https: // awebsrvr") DCOMSet object = DataSpace.CreateObject ( "ProgId" , "Machinename") Set Object = Dataspace.createObject ("Progid", ")

parameter

Object object variables are used to calculate objects that specify types in ProgID.

The DataSpace object variable represents the RDS.DataSpace object used to create a new object instance.

PROGID string, program ID, is used to identify server-side business objects that implement application business rules.

AWEBSRVR or MACHINENAME string, representative identifying the URL of the Internet Information Server (IIS) web server, the server business object instance is created on the server.

Description

The HTTP protocol is a standard Web protocol; HTTPS is a security web protocol. The DCOM protocol can be used when running on a local area where HTTP. The internal protocol is a local dynamic link library (DLL) and does not use the network.

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

New Post(0)