DataConnectionFileCollection Class
Represents the available Universal Data Connection (UDC) files located in the central data connection store on the server farm.
Inheritance Hierarchy
System.Object
Microsoft.SharePoint.Administration.SPPersistedObjectCollection<DataConnectionFile>
Microsoft.SharePoint.Administration.SPPersistedChildCollection<DataConnectionFile>
Microsoft.Office.InfoPath.Server.Administration.DataConnectionFileCollection
Namespace: Microsoft.Office.InfoPath.Server.Administration
Assembly: Microsoft.Office.InfoPath.Server (in Microsoft.Office.InfoPath.Server.dll)
Syntax
'Declaration
<GuidAttribute("F1C0C17B-0C07-4e44-92A9-4445922E301F")> _
Public NotInheritable Class DataConnectionFileCollection _
Inherits SPPersistedChildCollection(Of DataConnectionFile) _
Implements IBackupRestoreConfiguration, IBackupRestore
'Usage
Dim instance As DataConnectionFileCollection
[GuidAttribute("F1C0C17B-0C07-4e44-92A9-4445922E301F")]
public sealed class DataConnectionFileCollection : SPPersistedChildCollection<DataConnectionFile>,
IBackupRestoreConfiguration, IBackupRestore
Remarks
The UDC files that are available in the central data connection store on the server farm are listed on the Manage Data Connection Files page of the Central Administration site. A version 2 UDC file with the *.udcx file extension is designed for use by browser-enabled form templates that render in the browser or in the InfoPath editor. Form templates that are not browser-enabled can also use UDC files, however only administrator approved form templates can use UDC files managed by this collection.
Examples
In the following example, the DataConnectionFileCollection collection is used to loop through every UDC file on the server farm and write its display name to the console. Then the total number of UDC files on the server is written to the console.
Visual Basic
Dim LocalFormsService As FormsService
Dim LocalFarm As SPFarm
Dim UdcCollection As DataConnectionFileCollection
Dim UdcConnection As DataConnectionFile
Dim CountUdcFiles As Integer = 0
Try
LocalFarm = SPFarm.Local
LocalFormsService = LocalFarm.Services.GetValue(Of FormsService)(FormsService.ServiceName)
UdcCollection = LocalFormsService.DataConnectionFiles
For Each UdcConnection In UdcCollection
CountUdcFiles = CountUdcFiles + 1
Console.WriteLine("UDC file # " + CountUdcFiles.ToString() + ": " + UdcConnection.DisplayName)
Next
Console.WriteLine("Total UDC files on server: " + CountUdcFiles.ToString())
Console.Write("Press Enter to Continue")
Console.ReadLine()
Catch ex As Exception
Console.WriteLine("Error: " + ex.Message)
Console.Write("Press Enter to Continue")
Console.ReadLine()
End Try
C#
FormsService localFormsService;
SPFarm localFarm = SPFarm.Local;
int countUdcs = 0;
try
{
localFormsService = localFarm.Services.GetValue<FormsService>(FormsService.ServiceName);
DataConnectionFileCollection udcCollection = localFormsService.DataConnectionFiles;
string[] enumUdc = udcCollection.Enumerate("All");
foreach(DataConnectionFile udcConnection in udcCollection)
{
countUdcs++;
Console.WriteLine("UDC file # " + countUdcs.ToString() + ": " + udcConnection.DisplayName.ToString());
}
Console.WriteLine("Total UDC files on server: " + countUdcs.ToString());
Console.Write("Press Enter to Continue");
Console.ReadLine();
}
catch (Exception ex)
{
Console.WriteLine("Error: " + ex.Message);
Console.Write("Press Enter to Continue");
Console.ReadLine();
}
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.