Open Method of connection object and recordset object

Source: Internet
Author: User

ConnectionThe object uses the Open Method to open the connection, eliminating the need to use the commectionstring attribute.

Syntax:

ConnectionObject. Open
Connectionstring, userid, password, openoptions

Where:

· Connection object refers to the instance of the connection object defined for you;

· Connectionstring is optional and contains information about the connected database;

· Userid: optional, including the user name for establishing the connection;

· Password is optional and includes the user password for establishing a connection;

· Openoptions is optional. If it is set to adconnectasync, the connection will be opened asynchronously.

 

RecordsetThe open method of the object is used to open tables in the database.

There are two ways to open: one is to use the record set open method, the other is to use the connection object execute method.

(A) Open Method of record set

Syntax:

Recordset.Open Source, ActiveConnection, CursorType,
LockType, Options

Where:

· Recordset is the instance of the defined record set object.

· Source option, indicating the source information of the opened record. it can be a legal command, object variable name, SQL statement, table name, stored procedure call, or file name that saves the record set.

· Activeconnection: Optional. The variable name of a valid connection object or a string containing the connectionstring parameter.

· Cursortype can be used to determine the pointer type used to open record set objects.

· Locktype Option
Determine the lock type used to open record set objects.



(B) Execute method of the connection object

Syntax:

Set
recordset=Connection.Execute(CommandText,RecordsAffected,Options)

Parameter description:

· Commandtext
Returns the SQL command, table name, stored procedure, or specified text to be executed.

· Recordsaffected
Optional. Value of the long type. The number of records affected by the operation is returned.

· Options: optional, long type value, indicating how to handle the commandtext parameter.

 

After opening two objects, a series of operations are performed on the record. Take the query operation of the command object as an example.

CommandThe syntax of the execute method of the object is as follows:

Command.Execute RecordsAffected, Parameters, Options
'
Record set not returned
Or set
Rscordset = cmsad. Execute (recordsaffected, parameters, options) 'returns the record set

Commandtext Syntax:

Command.CommandText=stringvariable
Where:
Stringvariable is a string variable that contains SQL statements, table names, or stored procedures.

 

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.