Add(String, String, String, UInt32, String, String, String, String, String, String, String, String, String, String, String) Method

The Add method of the SPSiteCollection class creates an SPSite object in the collection based on the specified site URL, Web site title, description, locale identifier (LCID), and site definition or site template, as well as on the user names, user display names, and e-mail addresses of both the owner and a secondary contact, and on the database server, name for the new database, and the user name and password of the database administrator.

Parameters

strSiteUrl A string that contains the server-relative URL for the site object (for example, Site_Name or sites/Site_Name).

strTitle A string that contains the title of the site object.

strDescription A string that contains the description for the site object.

nLCID An unsigned 32-bit integer that specifies the LCID for the site object.

strWebTemplate A string that specifies the site definition or site template for the site object. Specify null to create a site without applying a template to it. The following table shows the values for the default site definitions included in an installation of Windows SharePoint Services.

Value Site Definition
STS#0 Team Site
STS#1 Blank Site
STS#2 Document Workspace
MPS#0 Basic Meeting Workspace
MPS#1 Blank Meeting Workspace
MPS#2 Decision Meeting Workspace
MPS#3 Social Meeting Workspace
MPS#4 Multipage Meeting Workspace

strOwnerLogin A string that contains the user name of the owner for the site object (for example, Domain\User). In Active Directory account creation mode, the strOwnerLogin parameter must contain a value even if the value does not correspond to an actual user name.

strOwnerName A string that contains the display name of the owner for the site object.

strOwnerEmail A string that contains the e-mail address of the owner for the site object.

strSecondaryContactLogin A string that contains the user name of a secondary contact for the site object (for example, Domain\User).

strSecondaryContactName A string that contains the display name of a secondary contact for the site object.

strSecondaryContactEmail A string that contains the e-mail address of a secondary contact for the site object.

strDatabaseServer A string that identifies the database server.

strDatabaseName A string that contains the name for the new database that is created.

strUsername A string that contains the user name of the database administrator (for example, Domain\User).

strPassword A string that contains the password for the database administrator.

Return Value

A Microsoft.SharePoint.SPSite object that represents the new top-level site.

Remarks

The Add method returns a Microsoft.SharePoint.SPException exception if values are specified for the Password and Username parameters when Microsoft Windows NT authentication is used for authentication in Microsoft SQL Server. Do not supply database credentials when using Windows NT authentication.

Example

The following code example creates a top-level site in the site collection of a specified virtual server.

Requirements

Platforms: Microsoft Windows Server 2003

Security: Code Access Security