Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Troubles to retrieve data from a sharepoint List 2013

$
0
0

Im having some troubles when i try to retrieve data from a list in sharepoint 2013.

SPSite osite = new SPSite(@"http://contoso.com");

  SPWeb web = osite.OpenWeb();

  SPList list = web.Lists["Calendar"];
  SPListItemCollection collection = list.Items;

  foreach (SPListItem item in collection)
  {
      Console.WriteLine(item["Title"]);
  }

And im getting this error: System.InvalidOperationException: Exception of type 'System.InvalidOperationException' was thrown.

I did a research in MSDN and i could connect to a diferent list in SharePoint 2010 using Visual Studio 2010, but now im using Visual Studio 2012 to connect to SharePoint 2013 and i dont get the same result.

Im using the DLL Microsoft.SharePoint. 15.0.0.0 

Thanks!


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>