Thursday, July 23, 2009

Deleting SPListItem using Web Service

I was working on adding/deleting list items using web services. When we have to delete the SPListItem from a document library/list, it is mandatory to mention ID of that SPListItem.

Ex.,


I cannot do something like this:



This way of coding would have helped more:
First, I would like to delete all the list items where City="Bengaluru".

Second, many a times we do not expose ID column for the user. So, we would be interested only in those columns which matters.

As a workaround, I had to use GetListItems to get the SPListItems where City = "Bengaluru" and then for each ID, execute UpdateListItems to delete those SPListItems.

Tuesday, July 7, 2009

GetDataTable() returns null

This actually bugged me for sometime! Look at this code:

SPListItemCollection results = list.GetItems (myQuery);
DataTable dtResults = results.GetDataTable();


Here, I'll execute a CAML (SPQuery) query against a list. From the SPListItemCollection, I'll try to get a DataTable.

If the SPListItemCollection is empty (i.e., results.Count = 0), the second line assigns null to dtResults. So, if you are referring to dtResults in the following lines, application throws NullReferenceException ("Object reference not set to an instance of an object"). I was expecting that, if there is no list item, the data table should be kind of empty table (no row but it should have schema).

So the summary is, whenever you are using GetDataTable(), make sure that you handle the null appropriately.

Friday, July 3, 2009

SharePoint Content Db in Suspect mode

While I was accessing my SharePoint site, suddenly, it threw the following error:

A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.)

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.)

A few times, I also got the following error:
Cannot open database "MyDb" requested by the login. The login failed.
Login failed for user 'Domain\Username'.

I opened SQL Server Management Studio and got to know that the Content Database was in "Suspect" mode. So, how do we bring this up to Normal mode.?! I did a quick googling and I got this article which shows step by step method to bring the database back to Normal mode. Of course, my content database is back to Normal!

A note: As per MSDN, the command sp_resetstatus will be removed in a future version of SQL Server. So, you may have to use ALTER DATABASE statement to achieve the same.

Monday, May 18, 2009

Runtime Error in method IViewHost.OnLoad

I noticed the following error in Event Viewer (under Application section):

Runtime Error in method IViewHost.OnLoad of type System.ArgumentException.The exception was System.ArgumentException: SAPHostName must be specified
at Microsoft.SharePoint.Portal.WebControls.IViewHost.get_Producer()
at Microsoft.SharePoint.Portal.WebControls.IViewHost.get_SSOApplicationName()
at Microsoft.SharePoint.Portal.WebControls.IViewHost.OnLoad(EventArgs args)

When I did search, all I could find was IViewHost.OnLoad is reserved for internal use and is not intended to be used directly from code. What is this error all about? Do I need to take any action to resolve this? Please let me know if you have any information on this error message.

I've also posted this question in MSDN forum. If I get any response, I'll update it here.

Thursday, February 12, 2009

Virtual TechDays

Registration is open for Microsoft Virtual TechDays...

Wednesday, February 11, 2009

MS BI Strategy Update

Microsoft has announced that it is consolidating the scorecard, dashboard, and analytical capabilities from PerformancePoint server into SharePoint server as PerformancePoint services. That means, SharePoint users can make use of these features without investing in PerformancePoint server. Read more here...

Thursday, April 17, 2008

Data Patterns

Here is a very good article on Data Patterns. Document is available in PDF format for download. Check it out: http://msdn2.microsoft.com/en-us/architecture/ms998446.aspx