SPContentDatabaseCollection class
參照至單一 Web 應用程式所使用的內容資料庫的集合。
Inheritance hierarchy
System.Object
Microsoft.SharePoint.Administration.SPAutoSerializingObject
Microsoft.SharePoint.SPBaseCollection
Microsoft.SharePoint.Administration.SPContentDatabaseCollection
Namespace: Microsoft.SharePoint.Administration
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'宣告
<GuidAttribute("4FFCB8E5-7B15-4b81-AC4E-99A2181AD33E")> _
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
Public Class SPContentDatabaseCollection _
Inherits SPBaseCollection
'用途
Dim instance As SPContentDatabaseCollection
[GuidAttribute("4FFCB8E5-7B15-4b81-AC4E-99A2181AD33E")]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
public class SPContentDatabaseCollection : SPBaseCollection
備註
使用SPSite類別的或SPWorkItemCollection類別的**ContentDatabase()**屬性可傳回網站集合或工作項目集合的內容資料庫。使用SPWebApplication類別之ContentDatabases屬性可傳回 Web 應用程式所使用的內容資料庫的集合。
若要新增內容資料庫,請使用**Add()**方法。
若要從集合中傳回單一內容資料庫使用索引器。例如,若集合已指派給變數myContentDatabases,使用以 C# myContentDatabases[index]或myContentDatabases(index)在 Visual Basic.NET 中,其中index是集合中之資料庫的索引編號,或是將內容資料庫的 GUID。
Examples
下列程式碼範例會顯示Microsoft SharePoint Foundation伺服器陣列內的所有 SharePoint Web 應用程式的內容資料庫的相關資訊。
Dim services As SPServiceCollection = SPFarm.Local.Services
Dim service As SPService
For Each service In services
If TypeOf service Is SPWebService Then
Dim webService As SPWebService = CType(service, SPWebService)
Dim webApplications As SPWebApplicationCollection = webService.WebApplications
Dim webApplication As SPWebApplication
For Each webApplication In webApplications
Dim contentDBs As SPContentDatabaseCollection = webApplication.ContentDatabases
Dim contentDB As SPContentDatabase
For Each contentDB In contentDBs
Response.Write((webApplication.DisplayName + " :: "
+ contentDB.CurrentSiteCount.ToString() + " :: "
+ contentDB.MaximumSiteCount.ToString() + " :: "
+ contentDB.Name + "<BR>"))
Next contentDB
Next webApplication
End If
Next service
SPServiceCollection services = SPFarm.Local.Services;
foreach (SPService service in services)
{
if (service is SPWebService)
{
SPWebService webService = (SPWebService)service;
SPWebApplicationCollection webApplications = webService.WebApplications;
foreach (SPWebApplication webApplication in webApplications)
{
SPContentDatabaseCollection contentDBs = webApplication.ContentDatabases;
foreach (SPContentDatabase contentDB in contentDBs)
{
Response.Write(webApplication.DisplayName + " :: "
+ contentDB.CurrentSiteCount.ToString() + " :: "
+ contentDB.MaximumSiteCount.ToString() + " :: "
+ contentDB.Name + "<BR>");
}
}
}
}
Thread safety
此類型的任何公用靜態 (在 Visual Basic 中的Shared ) 成員是多執行緒作業的安全。不保證執行個體成員安全執行緒。