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

ADO
ADO DataTypes
ADO 摘要
ADO 实例

ADO Open 方法


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

The Open method opens an existing Record object or creates a new file or directory.
Open的作用是:打开一个现有的Record[记录]对象或创建一个新的文件或目录。

Syntax
语法

Open(source,actconn,mode,createopt,opt,username,psword)

Parameter参数 Description描述
source Optional. The source parameter may be one of the following:
可选参数。可使用的源参数如下:
  • An absolute url
    一个绝对url
  • A relative url
    一个相对url
  • An open Recordset
    一个打开的记录集
  • Another Record object
    另一个记录对象
  • A Command object
    一个指令对象
  • An SQL SELECT statement
    一个SQL SELECT语句
  • A table name
    一个表名称
actconn Optional. A connection string or a Connection object
可选参数。指定一个连接字符串或连接对象
mode Optional. A ConnectModeEnum value, that indicates the access mode of the Record object. Default is adModeUnknown
可选参数。指定一个用来指示记录对象访问模式的ConnectModeEnum值。默认值为adModeUnknown
createopt Optional. A RecordCreateOptionsEnum value, that indicates whether an existing file/directory should be opened, or a new file/directory should be created. Default is adFailIfNotExists. This parameter will be ignored if the source parameter is not a URL
可选参数。指定一个用来指示是否需要打开一个现有的文件/目录或者是否需要创建一个新的文件/目录的RecordCreateOptionsEnum值。默认值为adFailIfNotExists。如果源参数不是一个URL,那么该参数将被忽略
opt Optional. One or more RecordOpenOptionsEnum values, that specifies the options for opening the Record. Default is adOpenRecordUnspecified
可选参数。指定一个用于指明记录开启选项的一个或多个RecordOpenOptionsEnum值。默认值为adOpenRecordUnspecified
username Optional. A user ID that authorizes access to source
可选参数。指定允许访问数据源的授权用户ID
psword Optional. A password that verifies the username
可选参数。指定授权用户的用户名相对应的密码

Example
案例

Example 1: source as the URL of a folder:

set rec = Server.CreateObject("ADODB.record")
rec.Open("http://www.w3schools.com/ado/")

Example 2: source as a relative URL in a Connection object:

set conn=Server.CreateObject("ADODB.Connection")
set rec = Server.CreateObject("ADODB.record")
conn.Open "URL=http://www.w3schools.com/ado/"
rec.Open("test.doc", conn)

Example 3: source as a row in a Recordset object:

set rs = Server.CreateObject("ADODB.recordset")
set rec = Server.CreateObject("ADODB.record")
rs.Open "test.doc", "URL=http://www.w3schools.com/ado/",,,adCmdTableDirect
rs.MoveLast() 
rec.Open(rs) 



ConnectModeEnum Values

Constant常量 Value值 Description描述
adModeUnknown 0 Default. Permissions have not been set or cannot be determined
默认值。表明权限尚未设置或无法确定
adModeRead 1 Read-only
只读
adModeWrite 2 Write-only
只写
adModeReadWrite 3 Read/write
可读/可写
adModeShareDenyRead 4 Prevents others from opening a connection with read permissions
防止其他用户使用读权限打开连接
adModeShareDenyWrite 8 Prevents others from opening a connection with write permissions
防止其他用户使用写权限打开连接
adModeShareExclusive 12 Prevents others from opening a connection
防止其他用户打开连接
adModeShareDenyNone 16 Allows others to open a connection with any permissions
防止其他用户使用任何权限打开连接
adModeRecursive 0x400000 Used with adModeShareDenyNone, adModeShareDenyWrite, or adModeShareDenyRead to set permissions on all sub-records of the current Record
组合使用adModeShareDenyNone、adModeShareDenyWrite或adModeShareDenyRead对当前记录的所有子记录设置权限


RecordCreateOptionsEnum Values

Constant常量 Value值 Description描述
adFailIfNotExists -1 Default. Fails if the source parameter points to a node that not exists
默认值。如果source[源]参数指向的节点不存在,那么操作将会失败
adCreateNonCollection 0 Creates a new Record of type adSimpleRecord
创建一个新的adSimpleRecord型记录
adCreateCollection 0x2000 Creates a new Record specified by the source parameter. If it points to an existing node, an error will occur. To prevent the error combine this value with adOpenIfExists or adCreateOverwrite
创建一个全新的由source参数指定的记录。如果指向的节点不存在,那么将产生错误。你可以事先使用adOpenIfExists或 adCreateOverwrite测试,以阻止错误的发生
adOpenIfExists 0x2000000 If the source points to an existing node or Record object, then the provider must open the existing Record instead of creating a new one. This value cannot be used with adCreateOverwrite
如果source参数指向一个现存的节点或Record[记录]对象,那么技术提供对象[provider]必须是打开现存的记录,而不是创建一个新的记录。该值不能与adCreateOverwrite一起使用
adCreateOverwrite 0x4000000 If the source points to an existing node or Record, then the existing Record will be overwritten and a new one is created in its place. This value cannot be used with adOpenIfExists
如果source参数指向一个现存的节点或Record[记录],那么现有的记录将被覆盖,并且在同一个位置将创建一个全新的记录。该值不能与adOpenIfExists一起使用
adCreateStructDoc 0x80000000 Creates a new Record of type adStructDoc
创建一个全新的adStructDoc型记录


RecordOpenOptionsEnum Values

Constant常量 Value值 Description描述
adOpenRecordUnspecified -1 Default. No options are specified
默认值。不指定任何选项
adOpenAsync 0x1000 Opens the Record object in asynchronous mode
以异步方式打开Record[记录]对象
adDelayFetchStream 0x4000 The default stream associated with the Record need not be retrieved initially
指定与记录相关的默认记录流不需要在一开始提取
adDelayFetchFields 0x8000 The fields associated with the Record need not be retrieved initially, but can be retrieved at the first attempt to access the field
指定与记录相关的字段不需要在一开始提取,但是可以在第一次尝试访问字段时提取
adOpenExecuteCommand 0x10000 The source contains command text that should be executed
指定包含执行指令文本的Source对象
adOpenOutput 0x800000 If the source points to a node that contains an executable script, then the opened Record will contain the results of the executed script. This value is only valid with non-collection records
如果source对象指向的节点包含了可执行的脚本程序,那么在打开的记录中将包含这个脚本执行后的结果。这个值仅在空集[non-collection]记录中有效

评论 (0) All

登陆 | 还没注册?