Share via


GetUsageData(Microsoft.SharePoint.Administration.SPUsageReportType, Microsoft.SharePoint.Administration.SPUsagePeriodType, Int32, System.DateTime) Method

The GetUsageData method of the SPWeb class returns a table that contains information about the usage of a Web site based on the specified type of report, time interval, number of columns to display, and last day to display.

Parameters

itemType   A Microsoft.SharePoint.Administration.SPUsageReportType value that specifies the type of report to create.

periodType   A Microsoft.SharePoint.Administration.SPUsagePeriodType value that specifies the time interval to use in the information returned.

numColsToDisplay   A 32-bit integer that specifies the number of columns to return in the table.

lastDayToDisplay   A System.DateTime value that specifies the most recent day to represent in the information returned. The value passed in this parameter must specify a time that is greater than or equal to the last time usage processing was run for the site.

Return Value

A System.Data.DataTable object that contains the information.

Remarks

The GetUsageData method returns undefined results when invalid parameters are passed (for example, a date from 100 years ago). If the value passed in the numColsToDisplay parameter is out of range, 31 columns are returned.

This method returns only 2000 records from the usage data for the site, while the GetUsageBlob method of Remote Procedure Call (RPC) protocol returns all usage data. For general information about usage event logging, see Usage Event Logging in Windows SharePoint Services.

Example

The following code example populates a DataGrid control with 12 columns of information about the usage of a site starting from yesterday.

This example requires using directives (Imports in Visual Basic) for the Microsoft.SharePoint, Microsoft.SharePoint.Administration, and Microsoft.SharePoint.WebControls namespaces.

Requirements

Platforms: Microsoft Windows Server 2003

Security: Code Access Security