DataSource.QueryConnection 属性

获取一个与数据源关联的 DataConnection 对象的引用。

命名空间:  Microsoft.Office.InfoPath
程序集:  Microsoft.Office.InfoPath(位于 Microsoft.Office.InfoPath.dll 中)

语法

声明
Public MustOverride ReadOnly Property QueryConnection As DataConnection
    Get
用法
Dim instance As DataSource
Dim value As DataConnection

value = instance.QueryConnection
public abstract DataConnection QueryConnection { get; }

属性值

类型:Microsoft.Office.InfoPath.DataConnection
与数据源关联的 DataConnection

备注

设置对 QueryConnection 属性返回的 DataConnection 对象的引用后,便可以使用特定的 DataConnection 对象提供的属性和方法。

此成员只能由与当前打开的表单在相同域中运行的表单访问,或者由已授予跨域权限的表单访问。

可以通过 Microsoft InfoPath Filler 或 Web 浏览器内打开的表单中运行的代码访问此类型或成员。

示例

在以下示例中,DataSource 对象的 QueryConnection 属性用于返回与 DataSource 对象(本例中为 ADOQueryConnection 对象)关联的数据连接的引用。然后,代码将使用 ADOQueryConnection 类的 Command() 属性在消息框中显示 SQL 命令文本。

AdoQueryConnection myConnection = 
   (AdoQueryConnection)(this.DataSources["CityList"].QueryConnection);
MessageBox.Show("SQL command text: " + myConnection.Command);
Dim myConnection As AdoQueryConnection  = _
   DirectCast(Me.DataSources("CityList").QueryConnection, _
   AdoQueryConnection) ;
MessageBox.Show("SQL command text: " & myConnection.Command)

另请参阅

引用

DataSource 类

DataSource 成员

Microsoft.Office.InfoPath 命名空间