This comes very handy .. How to enable the debugging in your newly created development Sharepoint Site.
Turn on the call stack (CallStack="true")
Disable custom errors in Visual Studio (<customerrors mode="Off"></customerrors>)
Enable compilation debugging (<compilation debug="true"></compilation>)
Monday, December 7, 2009
Wednesday, September 16, 2009
Good Practices How about this, to retrieve items from Large SPList
Use PortalSiteMapProvider (Microsoft Office SharePoint Server 2007 only).
Steve Peschka's white paper Working with Large Lists in Office SharePoint Server 2007 describes an efficient approach to retrieving list data in Office SharePoint Server 2007 by using the PortalSiteMapProvider class. PortalSiteMapProvider provides an automatic caching infrastructure for retrieving list data. The GetCachedListItemsByQuery method of PortalSiteMapProvider takes an SPQuery object as a parameter, and then checks its cache to determine whether the items already exist. If they do, the method returns the cached results. If not, it queries the list and stores the results in a cache. This approach works especially well when you are retrieving list data that does not change significantly over time. When data sets change frequently, the class incurs the performance cost of continually writing to the cache in addition to the costs of reading from the database. Consider that the PortalSiteMapProvider class uses the site collection object cache to store data. This cache has a default size of 100 MB. You can increase the size of this cache for each site collection on the object cache settings page for the site collection. But this memory is taken from the shared memory available to the application pool and can therefore affect the performance of other applications. Another significant limitation is that you cannot use the PortalSiteMapProvider class in applications based on Windows Forms. The following code example shows how to use this method.
Good Coding Practice
Using PortalSiteMap Provider
C#
// Get the current SPWeb object.
SPWeb curWeb = SPControl.GetContextWeb(HttpContext.Current);
// Create the query.
SPQuery curQry = new SPQuery();
curQry.Query = "
Hotel ";
// Create an instance of PortalSiteMapProvider.
PortalSiteMapProvider ps = PortalSiteMapProvider.WebSiteMapProvider;
PortalWebSiteMapNode pNode = ps.FindSiteMapNode(curWeb.ServerRelativeUrl) as PortalWebSiteMapNode;
// Retrieve the items.
SiteMapNodeCollection pItems = ps.GetCachedListItemsByQuery(pNode, "myListName_NotID", curQry, curWeb);
// Enumerate through all of the matches.
foreach (PortalListItemSiteMapNode pItem in pItems)
{
// Do something with each match.
}
Steve Peschka's white paper Working with Large Lists in Office SharePoint Server 2007 describes an efficient approach to retrieving list data in Office SharePoint Server 2007 by using the PortalSiteMapProvider class. PortalSiteMapProvider provides an automatic caching infrastructure for retrieving list data. The GetCachedListItemsByQuery method of PortalSiteMapProvider takes an SPQuery object as a parameter, and then checks its cache to determine whether the items already exist. If they do, the method returns the cached results. If not, it queries the list and stores the results in a cache. This approach works especially well when you are retrieving list data that does not change significantly over time. When data sets change frequently, the class incurs the performance cost of continually writing to the cache in addition to the costs of reading from the database. Consider that the PortalSiteMapProvider class uses the site collection object cache to store data. This cache has a default size of 100 MB. You can increase the size of this cache for each site collection on the object cache settings page for the site collection. But this memory is taken from the shared memory available to the application pool and can therefore affect the performance of other applications. Another significant limitation is that you cannot use the PortalSiteMapProvider class in applications based on Windows Forms. The following code example shows how to use this method.
Good Coding Practice
Using PortalSiteMap Provider
C#
// Get the current SPWeb object.
SPWeb curWeb = SPControl.GetContextWeb(HttpContext.Current);
// Create the query.
SPQuery curQry = new SPQuery();
curQry.Query = "
// Create an instance of PortalSiteMapProvider.
PortalSiteMapProvider ps = PortalSiteMapProvider.WebSiteMapProvider;
PortalWebSiteMapNode pNode = ps.FindSiteMapNode(curWeb.ServerRelativeUrl) as PortalWebSiteMapNode;
// Retrieve the items.
SiteMapNodeCollection pItems = ps.GetCachedListItemsByQuery(pNode, "myListName_NotID", curQry, curWeb);
// Enumerate through all of the matches.
foreach (PortalListItemSiteMapNode pItem in pItems)
{
// Do something with each match.
}
Friday, August 28, 2009
Monday, August 10, 2009
Exception 0x80020009 while activating sharepoint Publishing infrastructure feature
I had some issues while activating publishing feature for sharepoint. Found this issue was common for many users. This issue was solved using the command line tool STSADM
stsadm -o activatefeature -filename publishing\feature.xml -url http://serverURL -force
stsadm -o activatefeature -filename publishingresources\feature.xml -url http://serverURL -force
stsadm -o activatefeature -filename publishingSite\feature.xml -url http://serverURL -force
stsadm -o activatefeature -filename publishingweb\feature.xml -url http://serverURL -force
stsadm -o activatefeature -filename publishinglayouts\feature.xml -url http://serverURL -force
stsadm -o activatefeature -filename navigation\feature.xml -url http://serverURL -force
then do an IISRESET
stsadm -o activatefeature -filename publishing\feature.xml -url http://serverURL -force
stsadm -o activatefeature -filename publishingresources\feature.xml -url http://serverURL -force
stsadm -o activatefeature -filename publishingSite\feature.xml -url http://serverURL -force
stsadm -o activatefeature -filename publishingweb\feature.xml -url http://serverURL -force
stsadm -o activatefeature -filename publishinglayouts\feature.xml -url http://serverURL -force
stsadm -o activatefeature -filename navigation\feature.xml -url http://serverURL -force
then do an IISRESET
Monday, June 22, 2009
How to create Dropdownlist control for a SQL datasource using Sharepoint Designer
By default when you open a SQL datasource , and drag and drop the view to create a Input form for that datasource, the sharepoint point creates all fields as Text Boxes. This is not what a normal user wants.It would be greate when he can't choose a value from a dropdown and thus reduces the chances of duplicate records or wrongly spell words in the SQL tables.
Thus I have recreated the textbox control to dropdown, remember the main trick is
changing the textbox control to sharepoint inbuilt dvdropdownlist and change the binding to
'SelectedValue','SelectedIndexChanged'
<asp:SqlDataSource runat="server" id="SqlDataSource1" ConnectionString="Data Source=bwcmossdev;Initial Catalog=bwcSalesExec;User ID=sa;Password=webtech@123" ProviderName="System.Data.SqlClient" SelectCommand="SELECT rtrim(SALESMOT_SalesTeams.SalesTeamName) [SalesTeamName], SALESMOT_SalesTeams.SalesTeamManager, SALESMOT_SalesTeams.IsActive, Global_DivisionsNLocations.Description, SALESMOT_SalesTeams.SalesTeamID FROM SALESMOT_SalesTeams INNER JOIN Global_DivisionsNLocations ON SALESMOT_SalesTeams.SalesTeamDivision = Global_DivisionsNLocations.GlobalLocationId where SALESMOT_SalesTeams.isActive =1" />
<SharePoint:DVDropDownList runat="server" id="ff2{$Pos}" __designer:bind="{ddwrt:DataBind('i',concat('ff2',$Pos),'SelectedValue','SelectedIndexChanged','',ddwrt:EscapeDelims(string('')),'@SalesTeamID')}" selectedvalue="{@SalesTeamID}" datasourceid="SqlDataSource1" datatextfield="SalesTeamName" datavaluefield="SalesTeamID" />
Thus I have recreated the textbox control to dropdown, remember the main trick is
changing the textbox control to sharepoint inbuilt dvdropdownlist and change the binding to
'SelectedValue','SelectedIndexChanged'
<asp:SqlDataSource runat="server" id="SqlDataSource1" ConnectionString="Data Source=bwcmossdev;Initial Catalog=bwcSalesExec;User ID=sa;Password=webtech@123" ProviderName="System.Data.SqlClient" SelectCommand="SELECT rtrim(SALESMOT_SalesTeams.SalesTeamName) [SalesTeamName], SALESMOT_SalesTeams.SalesTeamManager, SALESMOT_SalesTeams.IsActive, Global_DivisionsNLocations.Description, SALESMOT_SalesTeams.SalesTeamID FROM SALESMOT_SalesTeams INNER JOIN Global_DivisionsNLocations ON SALESMOT_SalesTeams.SalesTeamDivision = Global_DivisionsNLocations.GlobalLocationId where SALESMOT_SalesTeams.isActive =1" />
<SharePoint:DVDropDownList runat="server" id="ff2{$Pos}" __designer:bind="{ddwrt:DataBind('i',concat('ff2',$Pos),'SelectedValue','SelectedIndexChanged','',ddwrt:EscapeDelims(string('')),'@SalesTeamID')}" selectedvalue="{@SalesTeamID}" datasourceid="SqlDataSource1" datatextfield="SalesTeamName" datavaluefield="SalesTeamID" />
Monday, June 15, 2009
Content DB Restore by SQL DB move, showing zero sites
First of all i'll tell you the steps how to copy your existing Site DB to a new Server.
STEP1: BACKUP:
Central Admin>Application Management>Content databases>Select web application from Right Hand Side Top drop down list
Database name will be displayed.
Step 2:Prepare the destination SQL server and Web server.
Then there might be an existing Content DB id in your sharepoint installation configuration DB.
Here is the workaround. First find out the Id of the sites (site collection) in the [restored_db].Sites then delete the line in the [Config_db].SiteMap with the same Id. Now attach the content_db and you should see the sites.
Or what you can do is change the ID inside the [config_db].SiteMap to something else, maybe change a number.
STEP1: BACKUP:
- On Source SQL Server: Backup SharePoint Content databases.
- Open SQL Server Enterprise manger
- Right Click a database (For ex: WSS_Content)>All Tasks>Backup Database>Database Complete>Backup to disk>Add>Filename>Provide a path & filename>Ok>Ok
Central Admin>Application Management>Content databases>Select web application from Right Hand Side Top drop down list
Database name will be displayed.
Step 2:Prepare the destination SQL server and Web server.
- Install the same versions of Service Packs for SQL and MOSS 2007, similar to your production server.
- Ensure you use the similar Admin user which would have full access as service account for both Web server and SQL server. (Check Security Administrators & Database Creators)
- Copy backup Content database files to Destination SQL Server
- Open SQL Server Enterprise manger
- Create a database in your destination SQL, give the same name that of your backed up DB
- Databases>Right Click>All Tasks>Restore database>Restore as Database>Type name of Content Database>From device>Select device>disk>Add>Browse to backup files>Ok>
- Create a new web application http://
at port 80 with content database name WSS_Content_TEST ( this Database we will remove and replace with out backed up DB) - Go to V3 Central Administration Page>Application Management>Create or extend Web Application
- Click on Create a new web application
- Choose any unused port no you can fancy
- Enter Database Server Name and enter Database name as WSS_Content_TEST
- Wait for operation to complete
- After application is created create a site collection, ( you can give any name eventually it'' not be used)
- Fill the details and select Team site template click Ok
- Browse to test site http://
- Check if it is working
To remove WSS_Content_TEST from a web application - Go to Central Administration, Central Administration > Application Management > Click on Content Databases
- On right hand side select the newly created web application if not already present
- Click on Database name WSS_Content_TEST
- Check remove content database checkbox and click OK
To attach restored content database to a new web application:
Open a command prompt and browse to
c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\Bin>
Run following command
stsadm -o addcontentdb -url http://-databaseserver Mossdev -databasename BackupDBName -assignnewdatabaseid
Where Mossdev is my Database server name
BackupDBName is my BackedUp Database that i've restored in SQL.
Check if the sites collection has be restored in your new server - Go to Central Administration, Central Administration > Application Management > Click on Content Databases
- On right hand side select the newly created web application if not already present
- Check the No. of sites in the site collection if its showing same no. that you had in your Restored Content DB webapplication.
- Then you are done with it. check the URL of the application, to view your restored Sharepoint Site.
Then there might be an existing Content DB id in your sharepoint installation configuration DB.
Here is the workaround. First find out the Id of the sites (site collection) in the [restored_db].Sites then delete the line in the [Config_db].SiteMap with the same Id. Now attach the content_db and you should see the sites.
Or what you can do is change the ID inside the [config_db].SiteMap to something else, maybe change a number.
Friday, May 22, 2009
Installing Sharepoint Visual Studio Extensions in XP machine Hack
We need to open up the Registry in the XP machine and create 12.0 folder then add a string value "Sharepoint"="Installed"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\12.0]
"Sharepoint"="Installed"
Thats it .. enjoy installing the development features of Sharepoint in XP machine.
Credit for discovering this hack goes to Janne Mattila's , he also got it from somewhere else.
Enjoy the Hack
Subscribe to:
Posts (Atom)