Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

AdoSubmitConnection.Connection property

Gets or sets the connection string used for an AdoSubmitConnection object.

Namespace:  Microsoft.Office.InfoPath
Assembly:  Microsoft.Office.InfoPath (in Microsoft.Office.InfoPath.dll)
public abstract string Connection { get; set; }

Property value

Type: System.String
The connection string for the data connection.

The Connection property of the ADOSubmitConnection object provides access to the connection string that is used by the ADO data connection to connect to an ActiveX Data Objects/OLEDB external data source.

Important noteImportant

An ADOSubmitConnection object can only exist when there is a corresponding ADOQueryConnection object, and the data connections represented by both objects share the same set of property values. Changing the value of this property for the ADOSubmitConnection object will also change the value of the same property for the corresponding ADOQueryConnection object.

NoteNote

The ADOSubmitConnection object is limited to work only with Microsoft SQL Server and Microsoft Access databases.

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 only from code running in forms opened in Microsoft InfoPath Filler.

In the following example, the event handler for a Button control uses the Connection property of the AdoSubmitConnection class to update the connection string for the secondary data source named Employees to point to a new server using the value entered in the ServerName field in the main data source. Then the Execute method of the DataConnection class is used to re-query the data connection on the new server.

public void ChangeServerName_Clicked(object sender, ClickedEventArgs e)
{
   // Get the Employees connection from the 
   //DataConnections collection.
   AdoSubmitConnection myAdoSubmitConnection = 
      (AdoSubmitConnection)(this.DataConnections["Employees"]);
   
   // Get the new server name from the ServerName field in 
   // the main data source.
   XPathNavigator myNav = 
      CreateNavigator().SelectSingleNode("/my:myFields/my:ServerName",
      NamespaceManager);
   string newServer = myNav.InnerXml;

   // Build the new connection string.
   string connectionString = 
      "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=True;";
   connectionString += "Initial Catalog=SalesDB;Data Source=" + 
      newServer;

   // Set the new connection string.
   myAdoSubmitConnection.Connection = connectionString;

   // Requery the data source.
   myAdoSubmitConnection.Execute();
}

Community Additions

Show:
© 2014 Microsoft. All rights reserved.