_ Recordsetptr's open function

Source: Internet
Author: User

From: http://hi.baidu.com/ruiqing_2008/blog/item/50381334c10183bbd1a2d369.html

_ Recordsetptr m_precordset; // create a _ recordsetptr m_precordset.createinstance ("ADODB. recordset"); // create an instance try {m_precordset-> open (

"Select * from duty", // SQL query statement
M_pconnection.getinterfaceptr (), // get the SQL connection pointer

// ConstAdopendynamic= 2' dynamic cursors are the most powerful, but consume the most resources. The added or deleted records modified by the user on the record description will be reflected in the record set. Supports full-featured browsing (access is not supported ).
Adopendynamic,

// Const adlockoptimistic = 3' the record set is locked only when the update method is called, and other operations before this can still change, insert, and delete the current record.

Adlockoptimistic,

//AdshorttextUse commandtext as the compile definition of a command or stored procedure call for computation.
Adcmdtext );
}
Catch (_ com_error E)
{
// Cout <e-> errormessage () <Endl;
Afxmessagebox ("create instance failed! ");
Return;
}

Content 1:

'Define some constants for database connection
Const adopenforwardonly = 0' (default) the cursor only browses records forward, does not support paging, recordset, bookmark
Const adopenkeyset = 1' indicates the keyset cursor. modifications made by other users to the record are reflected in the record set. However, adding or deleting records by other users is not reflected in the record set. Supports paging, recordset, and bookmark
ConstAdopendynamic= 2' dynamic cursors are the most powerful, but consume the most resources. The added or deleted records modified by the user on the record description will be reflected in the record set. Supports full-featured browsing (access is not supported ).
Const adopenstatic = 3' the static cursor is only a snapshot of the data. The changes you make to the record description, adding or deleting records, will not be reflected in the record set. Supports moving forward or backward

Const adlockreadonly = 1' (default) lock type, default, read-only, cannot be modified
Const adlockpessimistic = 2' lock the record immediately when editing, the safest way
Const adlockoptimistic = 3' the record set is locked only when the update method is called, and other operations before this can still change, insert, and delete the current record.
Const adlockbatchoptimistic = 4' records are not locked when being edited, but changes, inserts, and deletes are completed in the batch processing mode.

Const ad1_text = & h0001
Const adcmdtable = & h0002
%>

Open Method (ADO recordset)

Open the cursor.

Syntax

Recordset. Open source, activeconnection, cursortype, locktype, options

Content 2:

Commandtype attributes

Indicates the type of the command object.

Set and return values

Sets or returns a commandtypeenum value.

Constant description
AdshorttextUse commandtext as the compile definition of a command or stored procedure call for computation.
Adcmdtable uses commandtext as the name of all tables returned by internal SQL queries for its columns.
Adcmdtabledirect calculates commandtext as the name of all returned tables in its column.
Adcmdstoredproc uses commandtext as the name of the stored procedure for calculation.
Default Value of adcmdunknown. The command type in the commandtext attribute is unknown.
Ad1_file uses commandtext as the name of the persistent recordset file for calculation.
Adexecutenorecords indicates that commandtext is a command or stored procedure that does not return rows (for example, a command to insert data ). If any row is retrieved, these rows are discarded and no result is returned. It always worksAdshorttextOr adcmdstoredproc.

Description

You can use the commandtype attribute to optimize the calculation of the commandtext attribute.

If the value of the commandtype attribute is equal to adcmdunknown (default value), the system performance will decrease because ADO must call the provider to determine whether the commandtext attribute is an SQL statement, stored procedure, or table name. If you know the type of the command in use, you can directly go to the relevantCode. If the commandtype attribute does not match the command type in the commandtext attribute, an error occurs when the execute method is called.

the adexecutenorecords constant improves performance by minimizing internal processing. This constant is not used independently. It is always used with adshorttext or adshortstoredproc combination (for example, adshorttext + adexecutenorecords). If you use adexecutenorecords with recordset. Open, or use the command object in this method, errors will occur.

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.