当前位置: 首页 > 网络学院 > 服务端脚本教程 > ADO > ADO Open 方法
The Open method opens a connection to a data source. When the connection is open, you can execute commands against the data source.
Open方法的作用是:打开一个通往数据源的连接。当连接被打开时,你可以对数据源执行指令。
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 See the ConnectionString property for details. |
| 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值以决定该方法需要在连接建立之前还是之后返回 |
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 <%
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"
%> |
| Constant 常量 | Value值 | Description描述 |
|---|---|---|
| adConnectUnspecified | -1 | Default. Opens the connection synchronously (after). 默认值。同步打开连接 |
| adAsyncConnect | 16 | Opens the connection asynchronously (before). 非同步打开连接 |
评论 (0) All