SPContentDatabaseCollection 类

对内容数据库所使用的一个 Web 应用程序的引用的集合。

继承层次结构

System.Object
  Microsoft.SharePoint.Administration.SPAutoSerializingObject
    Microsoft.SharePoint.SPBaseCollection
      Microsoft.SharePoint.Administration.SPContentDatabaseCollection

命名空间:  Microsoft.SharePoint.Administration
程序集:  Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)

语法

声明
<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。

示例

下面的代码示例显示在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>");
            }
        }
    }
}

线程安全性

此类型的任何公共静态 (在 Visual Basic 中的Shared ) 成员是安全的多线程操作。不保证实例成员是线程安全。

另请参阅

引用

SPContentDatabaseCollection 成员

Microsoft.SharePoint.Administration 命名空间