当前位置: 首页 > 网络学院 > 服务端脚本教程 > ADO > ADO Execute 方法

ADO
ADO DataTypes
ADO 摘要
ADO 实例

ADO Execute 方法


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 480 ::
收藏到网摘: n/a

The Execute method executes the query, SQL statement or procedure specified in the CommandText property of the Command object.
Execute的作用是:执行在命令对象的CommandText属性中指定的查询语句、SQL语句或程序。

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]查询语句,那么它将返回一个关闭的记录对象。

Syntax for row-returning
row-returning[返回行]语法

Set rs=objcommand.Execute(ra,parameters,options)

Syntax for non-row-returning
non-row-returning[非返回行]语法

objcommand.Execute ra,parameters,options

Parameter
参数
Description
描述
ra Optional. Returns the number of records affected by a query. For a row-returning query, use the RecordCount property of the Recordset object to count of how many records are in the object.
可选参数。返回查询语句执行的记录数。对于一个row-returning[返回行]查询语句来说,可以使用记录对象中的RecordCount[由于输出记录数]属性来计算对象中包含的记录数量
parameters Optional. Parameter values passed with an SQL statement. Used to change, update, or insert new parameter values into the Parameters Collection.
可选参数。通过SQL语句传递的参数变量。它的作用是:改变、更新参数值或向参数集合中插入新的参数
options Optional. Sets how the provider should evaluate the CommandText property. Can be one or more CommandTypeEnum or ExecuteOptionEnum values. Default is adCmdUnspecified. 
可选参数。设置技术提供对象[provider]应该如何评估CommandText属性的功能。它可以是一个或多个CommandTypeEnumExecuteOptionEnum的值。默认值是adCmdUnspecified

Example
案例

<%
Set objcommand.Text="SELECT * FROM Customers"
objCommand.Execute
%>

or

<%
Set objcommand.Text="Customers"
objCommand.Execute(,,adCmdTableDirect)
%>


CommandTypeEnum Values

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一起使用


ExecuteOptionEnum Values

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.
指示主要线程在提取期间从未堵塞。如果所请求的行尚未提取,那么当前行将自动移到文件末尾。如果打开的记录流中的记录固定地包含一个记录,那么adAsyncFetchNonBlocking将不会产生作用;才作程序将同时运行以及阻塞该常量。当adCmdTableDirect选项用于打开记录时,adAsynchFetchNonBlocking将不会产生任何作用
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仅是返回一个单独行(该单独行作为一条记录对象返回)的一条指令或现存程序

评论 (0) All

登陆 | 还没注册?