Compartilhar via


SPDatabase Class

Encapsulates access to Microsoft SQL Server databases.

Inheritance Hierarchy

System.Object
  Microsoft.SharePoint.Administration.SPAutoSerializingObject
    Microsoft.SharePoint.Administration.SPPersistedObject
      Microsoft.SharePoint.Administration.SPPersistedUpgradableObject
        Microsoft.SharePoint.Administration.SPDatabase
          Microsoft.SharePoint.Administration.SPContentDatabase
          Microsoft.SharePoint.Administration.SPUsageDatabase
          Microsoft.SharePoint.BusinessData.SharedService.BdcServiceDatabase

Namespace:  Microsoft.SharePoint.Administration
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No

Syntax

'Declaration
<GuidAttribute("C1C16DA1-E487-439b-AE76-A38F61B66793")> _
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
Public Class SPDatabase _
    Inherits SPPersistedUpgradableObject _
    Implements IBackupRestore
'Usage
Dim instance As SPDatabase
[GuidAttribute("C1C16DA1-E487-439b-AE76-A38F61B66793")]
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
public class SPDatabase : SPPersistedUpgradableObject, IBackupRestore

Remarks

Use the Databases property of the SPDatabaseServiceInstance class, or the SPDatabaseCollection constructor, to return the collection of databases that support a database service instance.

Use an indexer to return a single database from the collection. For example, if the collection is assigned to a variable named myDatabases, use myDatabases[index] in C#, or myDatabases(index) in Visual Basic, where index is either the name or the GUID that identifies the database.

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.

See Also

Reference

SPDatabase Members

Microsoft.SharePoint.Administration Namespace