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

ADO
ADO介绍
ADO数据库连接
ADO记录集
ADO显示记录
ADO查询语句
ADO记录排序
ADO添加记录
ADO更新记录
ADO删除记录
ADO演示
ADO提升执行速度
ADO Command对象
ADO Connection对象
ADO Error
ADO Field
ADO Parameter
ADO 属性
ADO Record
ADO Recordset
ADO Stream

ADO Open 方法


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

The Open method opens a connection to a data source. When the connection is open, you can execute commands against the data source.
Open方法的作用是:打开一个通往数据源的连接。当连接被打开时,你可以对数据源执行指令。

Syntax
语法

connection.Open connectionstring,userID,password,options

Parameter参数 Description描述
connectionstring Optional. A string value that contains information about the connection. The string is composed of a series of parameter=value statements separated by semicolons.
可选参数。指定一个包含关于连接属性的字符串值。该字符串是由一系列的参数组成的。该参数是通过分号(;)隔开的值语句

Provider= the name of the provider
Provider= 技术提供对象的名称
File Name= the file that contains the connection information
File Name=包含连接信息的文件
Remote Provider= the name of the provider to open a client-side connection
Remote Provider=用于打开客户端连接的技术提供对象的名称
Remote Server= the path name to the server to open a client-side connection
Remote Server=用于打开客户端通往服务器连接的路径名称
URL= the absolute URL address to use for the connection. 
URL= 用于指示连接的绝对URL地址

See the ConnectionString property for details.
具体请参阅ConnectionString属性

userID Optional. A String value that contains a user name for the connection
可选参数。指定包含连接用户名的字符串值
password Optional. A String value that contains a password for the connection
可选参数。指定包含连接密码的字符串值
options Optional. A ConnectOptionEnum value that determines whether this method should return after or before the connection is established.
可选参数。指定一个ConnectOptionEnum值以决定该方法需要在连接建立之前还是之后返回

Example
案例

A DSN-less connection:
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
%>

A DSN-less connection with userID and password
(write the conn.open statement in ONE line):

<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;
data source=c:/webdata/northwind.mdb;
userID=xxx;
password=yyy"
%>

An ODBC Database Connection:

<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Open "northwind"
%>


ConnectOptionEnum

Constant 常量 Value值 Description描述
adConnectUnspecified -1 Default. Opens the connection synchronously (after).
默认值。同步打开连接
adAsyncConnect 16 Opens the connection asynchronously (before).
非同步打开连接

评论 (0) All

登陆 | 还没注册?