Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 11.0.1 (中文) » SQL Anywhere 服务器 - 数据库管理 » 启动并连接到数据库 » SQL Anywhere 数据库连接 » 使用 OLE DB 连接到数据库

 

从 ADO 连接

ADO 是一种面向对象的编程接口。在 ADO 中,Connection 对象代表与数据源建立的唯一会话。

您可以使用以下 Connection 对象的特性来启动连接:

  • 用于保存提供程序名称的 Provider 属性。如果您不提供 Provider 名称,ADO 将使用 MSDASQL 提供程序。

  • 用于保存连接字符串的 ConnectionString 属性。该属性保存 SQL Anywhere 连接字符串,其使用方式与 ODBC 驱动程序相同。您可以提供 ODBC 数据源名称,也可以明确指定 UserID、Password、DatabaseName 和其它参数,就像使用其它连接字符串一样。

  • Open 方法用于启动连接。

示例

以下 Visual Basic 代码启动与 SQL Anywhere 的 OLE DB 连接:

' Declare the connection object
Dim myConn as New ADODB.Connection
myConn.Provider = "SAOLEDB"
myConn.ConnectionString = "DSN=SQL Anywhere 11 Demo"
myConn.Open
另请参见