Share via


SPContentDatabaseCollection.Add Method (String, String, String, String, Int32, Int32, Int32)

Adds a content database to the collection of content databases that are used by the parent Web application and are based on specified database settings.

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

Syntax

'Declaration
Public Function Add ( _
    strDatabaseServer As String, _
    strDatabaseName As String, _
    strDatabaseUsername As String, _
    strDatabasePassword As String, _
    warningSiteCount As Integer, _
    maximumSiteCount As Integer, _
    status As Integer _
) As SPContentDatabase
'Usage
Dim instance As SPContentDatabaseCollection
Dim strDatabaseServer As String
Dim strDatabaseName As String
Dim strDatabaseUsername As String
Dim strDatabasePassword As String
Dim warningSiteCount As Integer
Dim maximumSiteCount As Integer
Dim status As Integer
Dim returnValue As SPContentDatabase

returnValue = instance.Add(strDatabaseServer, _
    strDatabaseName, strDatabaseUsername, _
    strDatabasePassword, warningSiteCount, _
    maximumSiteCount, status)
public SPContentDatabase Add(
    string strDatabaseServer,
    string strDatabaseName,
    string strDatabaseUsername,
    string strDatabasePassword,
    int warningSiteCount,
    int maximumSiteCount,
    int status
)

Parameters

  • strDatabaseServer
    Type: System.String

    A string that contains the name of the server for the database.

  • strDatabaseName
    Type: System.String

    A string that contains the name of the database.

  • strDatabaseUsername
    Type: System.String

    A string that contains the name of the owner of the database.

  • strDatabasePassword
    Type: System.String

    A string that contains the password for accessing the database.

  • warningSiteCount
    Type: System.Int32

    A 32-bit integer that specifies the number of sites that can be created before a warning event is generated and e-mail notification is sent to the database administrators.

  • maximumSiteCount
    Type: System.Int32

    A 32-bit integer that specifies the maximum number of sites to represent in the content database.

  • status
    Type: System.Int32

    A 32-bit integer that specifies the status for the database. 0 specifies that the status of the new database is Ready; 1 specifies that the status is Offline, which means that no new sites can be created in the database.

Return Value

Type: Microsoft.SharePoint.Administration.SPContentDatabase
A SPContentDatabase object that represents the new content database.

Examples

The following code example adds a content database to a specified virtual server and sets the status of the database to Ready.

Dim myUri As New Uri("http://myServer")
Dim webApp As SPWebApplication = SPWebApplication.Lookup(myUri)

Dim dbCollection As SPContentDatabaseCollection = webApp.ContentDatabases

dbCollection.Add("Database_Server", "Database_Name", Nothing, Nothing, 1000, 1000, 0)
Uri myUri = new Uri("http://myServer");
SPWebApplication webApp = SPWebApplication.Lookup(myUri);

SPContentDatabaseCollection dbCollection =webApp.ContentDatabases;

dbCollection.Add("Database_Server", "Database_Name", null, null, 1000, 1000, 0);

See Also

Reference

SPContentDatabaseCollection Class

SPContentDatabaseCollection Members

Add Overload

Microsoft.SharePoint.Administration Namespace