共用方式為


SPContentDatabase class

代表SharePoint Foundation部署中的內容資料庫。

Inheritance hierarchy

System.Object
  Microsoft.SharePoint.Administration.SPAutoSerializingObject
    Microsoft.SharePoint.Administration.SPPersistedObject
      Microsoft.SharePoint.Administration.SPPersistedUpgradableObject
        Microsoft.SharePoint.Administration.SPDatabase
          Microsoft.SharePoint.Administration.SPContentDatabase

Namespace:  Microsoft.SharePoint.Administration
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'宣告
<GuidAttribute("3D4F5451-1735-48bb-B920-76C1EC240B1D")> _
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
Public Class SPContentDatabase _
    Inherits SPDatabase _
    Implements IDatabaseSnapshotRestore, IMigratable
'用途
Dim instance As SPContentDatabase
[GuidAttribute("3D4F5451-1735-48bb-B920-76C1EC240B1D")]
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
public class SPContentDatabase : SPDatabase, 
    IDatabaseSnapshotRestore, IMigratable

備註

使用SPSite類別的或SPWorkItemCollection類別的**ContentDatabase()**屬性可傳回網站集合或工作項目集合的內容資料庫。使用SPWebApplication類別之ContentDatabases屬性可傳回 Web 應用程式所使用的內容資料庫的集合。

使用索引器的內容資料庫集合中傳回單一內容資料庫。例如,若集合已指派給變數myContentDatabases,使用myContentDatabases[index]以 C# 或 Visual Basic,其中index是集合中欄位的索引編號,或是將內容資料庫的 GUID 中myContentDatabases(index) 。

Examples

下列範例會使用GetChanges方法來報告,當使用者已刪除目前的網站集合為表示目前的變更記錄。

Dim siteCollection As SPSite = SPContext.Current.Site

Dim contentDB As SPContentDatabase = siteCollection.ContentDatabase

Dim myQuery As New SPChangeQuery(False, False)
myQuery.User = True
myQuery.Delete = True

Dim changes As SPChangeCollection = contentDB.GetChanges(myQuery)

Dim change As SPChange
For Each change In  changes
    Response.Write((" User deleted: " + change.Time.ToString() + "<BR>"))
Next change
SPSite siteCollection = SPContext.Current.Site;

SPContentDatabase contentDB = siteCollection.ContentDatabase;

SPChangeQuery myQuery = new SPChangeQuery(false, false);
myQuery.User = true;
myQuery.Delete = true;

SPChangeCollection changes = contentDB.GetChanges(myQuery);

foreach (SPChange change in changes)
{
    Response.Write(" User deleted: " + change.Time.ToString() + "<BR>");
}

Thread safety

此類型的任何公用靜態 (在 Visual Basic 中的Shared ) 成員是多執行緒作業的安全。不保證執行個體成員安全執行緒。

請參閱

參照

SPContentDatabase members

Microsoft.SharePoint.Administration namespace