VB Wonderful tutorial: Data asynchronous loading

Source: Internet
Author: User
Tags constant table name

Asynchronous loading is a data loading method of ADO, which is mainly controlled by the options parameter of the recordset.

ADO210. Format in CHM:

Recordset. Opensource,activeconnection,cursortype,locktype,options

Options

Optional. A Long value that indicates how the provider evaluates the source parameter, if the parameter represents something other than the command object, or that the recordset should be recovered from a previously saved file. Can be one or more [blocked ads]

A CommandTypeEnum or ExecuteOptionEnum value that can be combined with the bitwise AND operator.

ExecuteOptionEnum

Specifies how the provider executes the command.

Constant Value Description

ADASYNCEXECUTE0X10 indicates that the command will execute asynchronously.

The value cannot be combined with the value of the CommandTypeEnum adCmdTableDirect.

ADASYNCFETCH0X20 indicates that the remaining rows after the initial number specified in the CacheSize property are retrieved asynchronously.

ADASYNCFETCHNONBLOCKING0X40 indicates that the main thread will never block when retrieving. If the requested row is not retrieved, the current row moves to the end of the file itself.

If the recordset is opened from the stream containing the persistent storage recordset, then adasyncfetchnonblocking will not work, and the operation will occur synchronously and block.

Adasynchfetchnonblocking does not work when the adCmdTableDirect option is used to open the recordset.

ADEXECUTENORECORDS0X80 indicates that the command text is a command or stored procedure that does not return rows (for example, a command that inserts only data). If any rows are retrieved, they will be discarded and not returned.

adExecuteNoRecords can only be passed as an optional parameter to the command or connection Execute method.

ADEXECUTESTREAM0X400 indicates that the result of the command execution should be returned as a stream.

adExecuteStream can only be passed as an optional parameter to the command's Execute method.

Adexecuterecord indicates that CommandText is a command or stored procedure that returns a single line that should be returned as a record object.

AdOptionUnspecified-1 indicates that no command has been specified.

CommandTypeEnum

Specifies the method that interprets the command parameters.

Constant Value Description

AdCmdUnspecified-1 does not specify a parameter for the command type.

AdCmdText1 calculates CommandText by the text definition of a command or stored procedure call.

AdCmdTable2 computes CommandText by table name, which is all returned by an internally generated SQL query.

ADCMDSTOREDPROC4 computes CommandText by stored procedure name.

AdCmdUnknown8 default value. Indicates that the type of the command in the CommandText property is unknown.

AdCmdFile256 computes CommandText according to the file name of the persisted stored recordset. Used only with Recordset.Open or requery.

ADCMDTABLEDIRECT512 computes CommandText by the table name, and the table's columns are all returned. Used only with Recordset.Open or requery. To use the Seek method, you must open the recordset through adCmdTableDirect.

The value cannot be combined with the value of the ExecuteOptionEnum adAsyncExecute.

Generally use this parameter adasyncfetch to control, another need

. Properties ("Initalfetchsize") =50

In addition, we can refer to the development of VB Distributed application of MSCE

For example, Vb6.0 's code:

Dimadorsasadodb.recordset

Setadors=newadodb.recordset

Withadors

. Cursorlocation=aduseclient

. Properties ("Initialfetchsize") =50

. Openmstrsql,adocn,adopenstatic,adlockoptimistic,adasyncfetch

If.bof=falseor.eof=falsethen

'--------------

Else

Endif

Endwith

Summary: A lot of users ask a large number of loading problems, now this way can quickly return data. General 1 million data, the front 50 only need 5-6 seconds to return! The way to note this is:

1, if the amount of data is too large, and midway to cancel, you need to use Adocn.cancel to cancel the query, otherwise the data will continue to return data.

2, if the amount of data is too large, the release of the recordset will be problematic. Setadors=nothing does not quickly release the cache if the amount of data is 200m~300m. Hope that other users can provide their own insights.

3, on the large amount of data, C/s development in the provision of page-and-grid scroll bar combination of ways, to the user to talk is extremely convenient. Some users provide the use of stored procedures to achieve. I am in the development process with the page control and asynchronous loading of the data source combined to achieve a good data browsing.

Development environment: VB6.0 mssqlserver2k windowsads2k passed.

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.