ADOAdapter2.Connection 属性

定义

获取或设置用于 对象的 ADOAdapterObject 连接字符串。

public:
 property System::String ^ Connection { System::String ^ get(); void set(System::String ^ value); };
public string Connection { get; set; }
member this.Connection : string with get, set
Public Property Connection As String

属性值

实现

示例

// retrieve the Employees Adapter from the DataAdapters collection
ADOAdapter employeesDA = (ADOAdapter)thisXDocument.DataAdapters["Employees"];
// Get new server name from the main DOM
string newServer = thisXDocument.DOM.selectSingleNode("//my:serverName").text;
// build new connection string
string connectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=True;";
connectionString += "Initial Catalog=SalesDB;Data Source=" + newServer;
// set new connection string
employeesDA.<span class="label">Connection </span>= connectionString;
// query the data source again
DataObject employeesDO = thisXDocument.DataObjects["Employees"];
employeesDO.Query();

注解

ADOAdapter 对象的 Connection 属性包含 ADO 数据适配器使用的连接字符串,用以连接到 ActiveX 数据对象/OLEDB 外部数据源。

注意ADOAdapter 对象仅限于 Microsoft SQL Server 和 Microsoft Access 数据库。

适用于