Microsoft.SharePoint.Admini ...


SPContentDatabase Class (Microsoft.SharePoint.Administration)
Represents a content database that is part of a Windows SharePoint Services deployment.

Namespace: Microsoft.SharePoint.Administration
Assembly: Microsoft.SharePoint (in microsoft.sharepoint.dll)
Syntax

Visual Basic (Declaration)
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel:=True)> _
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel:=True)> _
Public Class SPContentDatabase
    Inherits SPDatabase
    Implements IMigratable
Visual Basic (Usage)
Dim instance As SPContentDatabase
C#
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel=true)] 
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel=true)] 
public class SPContentDatabase : SPDatabase, IMigratable
Remarks

Use the >ContentDatabase property of the SPSite class or of the SPWorkItemCollection class to return the content database for a site collection or work item collection. Use the ContentDatabases property of the SPWebApplication class to return the collection of content databases that are used by the Web application.

Use an indexer to return a single content database from a collection of content databases. For example, if the collection is assigned to a variable named myContentDatabases, use myContentDatabases[index] in Microsoft C#, or myContentDatabases(index) in Microsoft Visual Basic, where index is either the index number of the field in the collection or the GUID for the content database.

Example

The following example uses the GetChanges method to report when users have been deleted from the current site collection, as represented by the current change log.

Visual Basic
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
C#
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>");
}
Inheritance Hierarchy

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

Any public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread safe.

See Also

Tags :


Page view tracker