Friday, March 4, 2011

Moss 2007 - Excel Services no file permissions message

 If you receive the following Exception when you try to open the sample workbook or another workbook try the following steps:

You do not have permissions to open this file on Excel Services.Make sure that the file is in an Excel Services trusted location and that you have access to the file.

1.Open Central Administration -> go to Operations tab -Ensure that the Excel Service is running.
2.Open Central Administration -> go to your configured Shared Service -> click Excel Service Settings.

-File Access Method: ensure that it is not using Impersonation, instead the Option Process Account should be enabled.

3. Open Central Administration -> go to your configured Shared Service -> click add new trusted file location
-Field URL: here you can specify a report library or the whole portal
-Location Type: should be Windows SharePoint Services
-Children trusted: defines whether the children should also be trusted or only the definied path

Tuesday, January 25, 2011

IIS7 - Tell me plase why my debugger timed out - Coz u r slow -"The web server process that was being debugged has been terminated by IIS"

When you are debugging, IIS will not service any other requests until you are done stepping through your code. That includes the "ping" request that IIS sends to itself. Since IIS doesn't hear back from itself, it decides to shut itself down, which promptly terminates your debugging.
The solution is to increase the Ping Maximum Response Time in the application pool settings from its default value of 90 seconds. Set it to something high enough that will give you enough time to debug your code (like maybe 900 seconds). If you are not able to debug in 15 min, one should really look for a job which does include hardcore coding.

Tuesday, January 11, 2011

SPWeb GetList Exception from HRESULT: 0x80070003 System.IO.DirectoryNotFoundException

If you see something like this while calling while calling  SPWeb.GetList("BlahBlahBlah"), do not get alarmed.
All you need to provide is a site-relative URL like the following
"/sites/myWeb/Lists/myCoolList".
If you are in the top-lelel site collection and wondering what the heck , then it should be like "/Lists/myCoolList"

"Unhandled Exception: System.IO.DirectoryNotFoundException: The system cannot find the path specified. (Exception from HRESULT: 0x80070003)"

Deleting Document Library Items for large list size Failed?

For novice to use this code, specify the strings variables siteURL, listName.
The maximum items that your program can delete is 25000 which can be changed.

Hey friends, If you have saved lot of time using my code, please pay me by smiling at all the people you see today. They will smile back at you. We will all be in a pool of happy smiles. If you have a big wallet, feed a hungry stomach today.  And God will bless you.

using (SPSite site = new SPSite(siteURL))
{
 using (SPWeb web = site.OpenWeb())
                {
                    web.AllowUnsafeUpdates = true;
                    StringBuilder sbDelete = new StringBuilder();
                    SPList spList = web.GetList("/" + listName);
                    sbDelete.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Batch>");
                    string command = "<Method><SetList Scope=\"Request\">" + spList.ID +
                        "</SetList><SetVar Name=\"ID\">{0}</SetVar><SetVar Name=\"Cmd\">Delete</SetVar><SetVar Name=\"owsfileref\">{1}</SetVar></Method>";
                    int limit = 0;
                    foreach (SPListItem item in spList.Items)
                    {
                        limit++;
                        if (limit > 25000)
                            break;
                        sbDelete.Append(string.Format(command, item.ID.ToString(), item.File.Url));
                    }
                    sbDelete.Append("</Batch>");

                    web.ProcessBatchData(sbDelete.ToString());
                    web.Update();
                    web.AllowUnsafeUpdates = false;
                }
}

Deleting ListItems for large list size Failed?

The following code only works for List. Refer my other post for Document Library.
For novice to use this code, specify the strings variables siteURL, listName.

The maximum items that your program can delete is 5000 which can be changed.


The way web.Lists[listName] works is that it loads the meta-data information of the all lists for that specific SPWeb object and then it does SPList.Title comparison with metadata of all the lists returned and returns the first matching list from the SPWeb.Lists collection. This has got two implications:
1. The loading of list is slow as the meta-data information of all the list is loaded and then comparison happens on list name specified.
2. If there are large numbers of lists in a specific SPWeb, the process of getting the meta-data information of all the available lists may introduce transaction lock in backend database when multiple such calls happen in quick succession.

The suggested way to access a list is by using SPWeb.GetList(string url). In this case, first the GUID of list is figured out and then meta-data for the list is loaded. Obviously, this is a faster way also.
If your head is already spinning, the summary is that
"And you must use  web.GetList(listName) instead of web.Lists[listName]. Otherwise it may take for ever."

Hey friends, If you have saved lot of time using my code, please pay me by smiling at all the people you see today. They will smile back at you. We will all be in a pool of happy smiles. If you have a big wallet, find & feed a hungry stomach today(not mine).  And God will bless you.

using (SPSite site = new SPSite(siteURL))
{

 using (SPWeb web = site.OpenWeb())
                {
                    web.AllowUnsafeUpdates = true;
                    StringBuilder sbDelete = new StringBuilder();

                   SPList spList = web.GetList("/Lists/" + listName);

                    sbDelete.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Batch>");
                    string command = "<Method><SetList Scope=\"Request\">" + spList.ID +
                        "</SetList><SetVar Name=\"ID\">{0}</SetVar><SetVar Name=\"Cmd\">Delete</SetVar></Method>";
                    int limit = 0;
                    foreach (SPListItem item in spList.Items)
                    {
                        limit++;
                        if (limit > 5000)
                            break;
                        sbDelete.Append(string.Format(command, item.ID.ToString()));
                    }
                    sbDelete.Append("</Batch>");

                    web.ProcessBatchData(sbDelete.ToString());
                    web.Update();
                    web.AllowUnsafeUpdates = false;
                }
}

Wednesday, December 29, 2010

SharaPoint CAML OrderBy DefaultView Limit

The Default List view has direct effect on the number of records that return for the CAML query with OrderBy.
Changed the List's Default View limit to 5 and U see only 5items. Wierd One.
Hope this post will save a lot of time for people researching what the heck happened

Thursday, November 18, 2010

Truncate and shrink Transaction Log file in SQL Server 2008

SQL Server 2008

In SQL Server this process have been changed. In 2008, just change the recovery model to simple and then use DBCC Shrinkfile command.

use [YourDatabaseName]
select name,recovery_model_desc from sys.databases
GO
Alter database [YourDatabaseName] Set Recovery SIMPLE
GO
Declare @LogFileLogicalName sysname
select @LogFileLogicalName=Name from sys.database_files where Type=1
print @LogFileLogicalName

DBCC Shrinkfile(@LogFileLogicalName,1)



______________________________

If you may want to set the recovery back to Full. If so, add the following.
Alter database [YourDatabaseName] Set Recovery FULL