当前位置: 首页 > 网络学院 > 服务端脚本教程 > ADO > ADO Execute 方法
The Execute method executes a specified query, SQL statement, stored procedure, or provider-specific text.
Execute的作用是:执行一个查询语句、陈述语句、程序或技术提供对象[provider]的详细文本。
The results are stored in a new Recordset object if it is a row-returning query. A closed Recordset object will be returned if it is not a row-returning query.
如果返回行[row-returning]查询语句,那么结果将被存储在一个新的记录对象中;如果它不是一个返回行[row-returning]查询语句,那么它将返回一个关闭的记录对象。
Note: The returned Recordset is always a read-only, forward-only Recordset!
注意:返回的Recordset是一个只读的、只向前兼容的Recordset。
Tip: To create a Recordset with more functionality, first create a Recordset object. Set the desired properties, and then use the Recordset object's Open method to execute the query.
提示:在第一次创建Recordset对象时,需要将它创建为一个更具功能性的Recordset对象。设置一个我们所希望的属性,使用Recordset对象的Open方法去执行查询语句。
Set objrs=objconn.Execute(commandtext,ra,options) |
objconn.Execute commandtext,ra,options |
Parameter参数 | Description描述 |
---|---|
commandtext | Required. The SQL statement, stored procedure, or provider-specific text to execute 必要参数。指定需要执行的SQL语句,现存的程序或技术提供对象[provider]的详细文本 |
ra | Optional. The number of records affected by the query 可选参数。返回查询语句执行的记录数 |
options | Optional. Sets how the provider should evaluate the commandtext parameter. Can be one or more CommandTypeEnum or ExecuteOptionEnum values. Default is adCmdUnspecified 可选参数。设置技术提供对象[provider]应该如何评估CommandText属性的功能。它可以是一个或多个CommandTypeEnum 或 ExecuteOptionEnum的值。默认值是adCmdUnspecified |
<% sql="SELECT companyname FROM Customers" Set rs=conn.Execute(sql) %> |
Constant常量 | Value值 | Description描述 |
---|---|---|
adCmdUnspecified | -1 | Does not specify the command type argument. 不指定指令类型自变量 |
adCmdText | 1 | Evaluates CommandText as a textual definition of a command or stored procedure call. 指示提供者应该将Source作为命令的文本定义来计算。 |
adCmdTable | 2 | Evaluates CommandText as a table name whose columns are all returned by an internally generated SQL query. 指示ADO生成SQL查询以便从在Source中命名的表中返回所有行 |
adCmdStoredProc | 4 | Evaluates CommandText as a stored procedure name. 将CommandText作为一个已存的程序名称 |
adCmdUnknown | 8 | Indicates that the type of command in the CommandText property is not known. 默认值。指定未知的CommandText属性命令 |
adCmdFile | 256 | Evaluates CommandText as the file name of a persistently stored Recordset. Used with Recordset.Open or Requery only. 指示应从在Source中命名的文件中恢复保留(保存的)Recordset。它仅能与Recordset.Open 或 Requery 指令一起使用 |
adCmdTableDirect | 512 | Evaluates CommandText as a table name whose columns are all returned. Used with Recordset.Open or Requery only. To use the Seek method, the Recordset must be opened with adCmdTableDirect. This value cannot be combined with the ExecuteOptionEnum value adAsyncExecute. 指示提供者更改从在 Source 中命名的表中返回所有行/ 将CommandText作为一个表的名称(该表的列全部是通过内部的SQL查询语句返回的)。它仅适用Recordset.Open 或 Requery 指令;如果需要使用查找方式,那么Recordset必须以adCmdTableDirect打开。这个值不能与ExecuteOptionEnum值 adAsyncExecute一起使用 |
Constant常量 | Value值 | Description描述 |
---|---|---|
adOptionUnspecified | -1 | Indicates that the command is unspecified. 指明为指定的指令 |
adAsyncExecute | Indicates that the command should execute asynchronously. This value cannot be combined with the CommandTypeEnum value adCmdTableDirect. 指明指令是否需要异步执行。这个值不能与CommandTypeEnum 之中的adCmdTableDirect一起使用 | |
adAsyncFetch | Indicates that the remaining rows after the initial quantity specified in the CacheSize property should be retrieved asynchronously. 指明在CacheSize属性中指定了初始量以后,是否应该异步获取保留行[remaining rows] | |
adAsyncFetchNonBlocking | Indicates that the main thread never blocks while retrieving. If the requested row has not been retrieved, the current row automatically moves to the end of the file. If you open a Recordset from a Stream containing a persistently stored Recordset, adAsyncFetchNonBlocking will not have an effect; the operation will be synchronous and blocking. adAsynchFetchNonBlocking has no effect when the adCmdTableDirect option is used to open the Recordset. | |
adExecuteNoRecords | Indicates that the command text is a command or stored procedure that does not return rows (for example, a command that only inserts data). If any rows are retrieved, they are discarded and not returned. adExecuteNoRecords can only be passed as an optional parameter to the Command or Connection Execute method. 它仅指明了指令文本仅是一条不返回任何行的指令或现存程序(如:一条只执行数据插入的指令)。如果没有任何行被提取,那么他们将放弃执行并不返回任何值。 adExecuteNoRecords仅可以作为一个可选参数传递到指令中或连接执行方法[Connection Execute method]中 | |
adExecuteStream | Indicates that the results of a command execution should be returned as a stream. adExecuteStream can only be passed as an optional parameter to the Command Execute method. 指明需要以结果流的形式返回命令执行的结果。adExecuteStream仅可以作为一个可选参数传递到指令中或连接执行方法[Connection Execute method]中 | |
adExecuteRecord | Indicates that the CommandText is a command or stored procedure that returns a single row which should be returned as a Record object. 指明CommandText仅是返回一个单独行(该单独行作为一条记录对象返回)的一条指令或现存程序 |