XmlForm.QueryDataConnection Property

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
    Get
'Usage
Dim instance As XmlForm
Dim value As DataConnection

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

Property Value

Type: Microsoft.Office.InfoPath.DataConnection
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.

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 InfoPath Filler or in a Web browser.

Examples

In the following code 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