Recently I got a request from a client to get a report of the number of items they had in the document libraries on their site. They wanted it broken down with the number of files per site, document library, and eventually per folder. Anyways its a fairly simple procedure (or so I think anyways), but figured I’d post it up since its been a while since I’ve thrown anything up. The code is broken into two methods, the first is used to iterate through all the child webs of a given SPWeb and also iterates through all the lists for that web and then calls the second method to interate through all the folders in a given list.
public void CrawlWeb(SPWeb web)
{
foreach (SPList list in web.Lists)
{
CrawlFolder(list.RootFolder);
}
foreach (SPWeb subWeb in web.Webs)
{
CrawlWeb(subWeb);
}
}
public void CrawlFolder(SPFolder folder)
{
if (folder != null && folder.Name.CompareTo(“forms”) != 0)
{
foreach (SPFolder subFolder in folder.SubFolders)
{
CrawlFolder(subFolder);
}
}
}
Tuesday, March 31, 2009
Tuesday, March 17, 2009
adding a new menu Item in Sharepoint. (SharePoint Features)
WSS 3.0 - How to create new SharePoint Feature?
How to create New Feature in WSS 3.0? / MOSS 2007
How to add new menu item under “Site Settings” menu in wss 3.0?
1. Create a new folder, called “SabinsNewFeature”, in C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES
2. Create an Xml file, called “feature.xml” in the “MyListUserFeature” folder
3. Edit the feature.xml file and add the following content
Title="Feature My List User Feature"
Description="Custom action on Site Actions"
Version="1.0.0.0"
Scope="Site"
xmlns="http://schemas.microsoft.com/sharepoint/">
4. Replace the GUID placeholder in the previous Id attribute, generate a GUID by running guidgen.exe, located in Local_Drive:\Program Files\Microsoft Visual Studio 8\Common7\Tools.
Create an Xml file, called “ListUsers.xml” in the “SabinsNewFeature” folder
5. Edit the file and add the following content
GroupId = "SiteActions"
Location="Microsoft.SharePoint.StandardMenu"
Sequence="1000"
Title="List Users">
6. Install the new feature by running the following command by going to Start>Run>cmd
change to the following directory: %COMMONPROGRAMFILES%\Microsoft shared\Web server extensions\12\Bin. (Because, STSADM.EXE sits in this folder )
Execute the following command from the above location
Stsadm –o installfeature –filename SabinsNewFeature\feature.xml
You will get a message saying "Operation completed Successfully"
7. Activate the new feature by running the following command
stsadm –o activatefeature -filename SabinsNewFeature\feature.xml -url http://siteurl
if your site has been in the port,
stsadm –o activatefeature -filename SabinsNewFeature\feature.xml -url http://siteul:port number
Now you will see the new menu item in the "Site Settings" of the site that you installed the feature.
How to create New Feature in WSS 3.0? / MOSS 2007
How to add new menu item under “Site Settings” menu in wss 3.0?
1. Create a new folder, called “SabinsNewFeature”, in C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES
2. Create an Xml file, called “feature.xml” in the “MyListUserFeature” folder
3. Edit the feature.xml file and add the following content
Description="Custom action on Site Actions"
Version="1.0.0.0"
Scope="Site"
xmlns="http://schemas.microsoft.com/sharepoint/">
4. Replace the GUID placeholder in the previous Id attribute, generate a GUID by running guidgen.exe, located in Local_Drive:\Program Files\Microsoft Visual Studio 8\Common7\Tools.
Create an Xml file, called “ListUsers.xml” in the “SabinsNewFeature” folder
5. Edit the file and add the following content
Location="Microsoft.SharePoint.StandardMenu"
Sequence="1000"
Title="List Users">
6. Install the new feature by running the following command by going to Start>Run>cmd
change to the following directory: %COMMONPROGRAMFILES%\Microsoft shared\Web server extensions\12\Bin. (Because, STSADM.EXE sits in this folder )
Execute the following command from the above location
Stsadm –o installfeature –filename SabinsNewFeature\feature.xml
You will get a message saying "Operation completed Successfully"
7. Activate the new feature by running the following command
stsadm –o activatefeature -filename SabinsNewFeature\feature.xml -url http://siteurl
if your site has been in the port,
stsadm –o activatefeature -filename SabinsNewFeature\feature.xml -url http://siteul:port number
Now you will see the new menu item in the "Site Settings" of the site that you installed the feature.
Wednesday, March 4, 2009
SQL Server: "Cannot open user default database" Error 4064
SQL Server 2005
You can use the sqlcmd utility to change the default database in SQL Server 2005. To do this, follow these steps:
Click Start, click Run, type cmd, and then press ENTER.
Use one of the following methods, depending on the kind of authentication that the SQL Server login uses:
If the SQL Server login uses Microsoft Windows authentication to connect to the instance, type the following at the command prompt, and then press ENTER:
sqlcmd –E -S InstanceName –d master
If the SQL Server login uses SQL Server authentication to connect to the instance, type the following at the command prompt, and then press ENTER:
sqlcmd -S InstanceName -d master -U SQLLogin -P Password
Note InstanceName is a placeholder for the name of the SQL Server 2005 instance to which you are connecting. SQLLogin is a placeholder for the SQL Server login whose default database has been dropped. Password is a placeholder for the SQL Server login password.
At the sqlcmd prompt, type the following, and then press ENTER:
ALTER LOGIN SQLLogin WITH DEFAULT_DATABASE = AvailDBName
Note AvailDBName is a placeholder for the name of the existing database that can be accessed by the SQL Server login in the instance.
At the sqlcmd prompt, type GO, and then press ENTER.
You can use the sqlcmd utility to change the default database in SQL Server 2005. To do this, follow these steps:
Click Start, click Run, type cmd, and then press ENTER.
Use one of the following methods, depending on the kind of authentication that the SQL Server login uses:
If the SQL Server login uses Microsoft Windows authentication to connect to the instance, type the following at the command prompt, and then press ENTER:
sqlcmd –E -S InstanceName –d master
If the SQL Server login uses SQL Server authentication to connect to the instance, type the following at the command prompt, and then press ENTER:
sqlcmd -S InstanceName -d master -U SQLLogin -P Password
Note InstanceName is a placeholder for the name of the SQL Server 2005 instance to which you are connecting. SQLLogin is a placeholder for the SQL Server login whose default database has been dropped. Password is a placeholder for the SQL Server login password.
At the sqlcmd prompt, type the following, and then press ENTER:
ALTER LOGIN SQLLogin WITH DEFAULT_DATABASE = AvailDBName
Note AvailDBName is a placeholder for the name of the existing database that can be accessed by the SQL Server login in the instance.
At the sqlcmd prompt, type GO, and then press ENTER.
Tuesday, March 3, 2009
Enable remote connections to the SQL Server 2005 instance that hosts the report server database
Click Start, point to Programs, point to Microsoft SQL Server 2005,
oint to Configuration Tools, and click SQL Server Surface Area Configuration Tool.
Click Surface Area Configuration for Services and Connections.
Open the folder for the SQL Server instance that hosts the report server databases.
Click 'Remote Connections' under 'Database Engine'
Click Local and Remote Connections.
Click Using both TCP/IP and named pipes.
Click OK, and then restart the service by selecting "service" and clicking the "Stop" button at the right pane.
click "Start" button after stoping it.
oint to Configuration Tools, and click SQL Server Surface Area Configuration Tool.
Click Surface Area Configuration for Services and Connections.
Open the folder for the SQL Server instance that hosts the report server databases.
Click 'Remote Connections' under 'Database Engine'
Click Local and Remote Connections.
Click Using both TCP/IP and named pipes.
Click OK, and then restart the service by selecting "service" and clicking the "Stop" button at the right pane.
click "Start" button after stoping it.
Subscribe to:
Posts (Atom)