Share via


XmlForm.QueryDataConnection Property (Microsoft.Office.InfoPath)

Gets a reference to the DataConnection object that represents the data connection that is associated with the form.

Namespace: Microsoft.Office.InfoPath
Assembly: Microsoft.Office.InfoPath (in microsoft.office.infopath.dll)

Syntax

'Declaration
Public MustOverride ReadOnly Property QueryDataConnection As DataConnection
'Usage
Dim instance As XmlForm
Dim value As DataConnection

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

Property Value

A DataConnection that represents the data connection that is associated with the form.

Remarks

DataConnection objects provide properties and methods that retrieve and submit data to external data sources; the data connection that is associated with a form is dependent on the type of data source that was used when the form was initially created.

The QueryDataConnection property allows you to access an InfoPath form's primary data source. To access the data adapter objects used for a form's secondary data sources, use the DataSources property.

Note

The QueryDataConnection property provides similar functionality to the QueryAdapter property of the XDocument object in the COM/Scripting object model, and to the QueryAdapter property of the _XDocument2 interface of the InfoPath 2003-compatible managed code object model.

This member can be accessed only by forms running in the same domain as the currently open form, or by forms that have been granted cross-domain permissions.

This type or member can be accessed from code running in forms opened in Microsoft Office InfoPath 2007 or in a Web browser.

Example

In the following example, the QueryDataConnection property of the XmlForm class is used to set a reference to the ADOQueryConnection and ADOSubmitConnection objects associated with the form template. Then the Command property of the ADOQueryConnection object and the Command property of the ADOQueryConnection objects are used to display the SQL command text for each connection type in a message box

ADOQueryConnection queryConnection;
ADOSubmitConnection submitConnection;

queryConnection = (ADOQueryConnection) this.QueryConnection;
MessageBox.Show("Query SQL command text: " + queryConnection.Command);

submitConnection = (ADOSubmitConnection) this.QueryConnection;
MessageBox.Show("Submit SQL command text: " + querySubmit.Command);
Dim queryConnection As ADOQueryConnection
Dim submitConnectionmAs ADOSubmitConnection

queryConnection = DirectCast(ADOQueryConnection, Me.QueryConnection)
MessageBox.Show("Query SQL command text: " & queryConnection.Command)

submitConnection = DirectCast(ADOSubmitConnection, Me.QueryConnection)
MessageBox.Show("Submit SQL command text: " & querySubmit.Command)

See Also

Reference

XmlForm Class
XmlForm Members
Microsoft.Office.InfoPath Namespace