简体   繁体   English

从列表共享点2013获取数据的麻烦

[英]Troubles on getting data from a List sharepoint 2013

Im having some troubles when i try to retrieve data from a list in sharepoint 2013. 我在尝试从sharepoint 2013中的列表中检索数据时遇到麻烦。

  SPSite osite = new SPSite(@"http://win-kee1pn6mrku");

  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: error 我得到这个错误: 错误

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. 我在MSDN上进行了研究,可以使用Visual Studio 2010连接到SharePoint 2010中的其他列表,但是现在我使用Visual Studio 2012连接到SharePoint 2013,但我没有得到相同的结果。

Im using the DLL Microsoft.SharePoint. 我正在使用DLL Microsoft.SharePoint。

Thanks! 谢谢!

i think there is something wrong when you declare the SPSite, maybe you don't need @, so: 我认为在声明SPSite时出了点问题,也许您不需要@,所以:

SPSite osite = new SPSite("http://win-kee1pn6mrku");

But, I usually using: 但是,我通常使用:

string siteURL = SPContext.Current.Web.Url;
SPSite oSite = new SPSite(siteURL);

Hope this helps. 希望这可以帮助。

You could take a look at this article too: 您也可以看一下这篇文章:

http://social.msdn.microsoft.com/Forums/en-US/1e939d9c-0fbb-44bf-9af1-a37594d2041a/differences-between-spcontextcurrentsiteurl-and-spcontextcurrentweburl http://social.msdn.microsoft.com/Forums/zh-CN/1e939d9c-0fbb-44bf-9af1-a37594d2041a/differences-between-spcontextcurrentsiteurl-and-spcontextcurrentweburl

If you are trying to get this data from client side, you should use the Microsoft.SharePoint.Client DLLs. 如果尝试从客户端获取此数据,则应使用Microsoft.SharePoint.Client DLL。 For communicating with SharePoint 2013 you probably should get those files from the server, because the aren't yet available in a NuGet Package. 与SharePoint 2013通信时,您可能应该从服务器获取这些文件,因为NuGet包中尚不提供这些文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Sharepoint 2013,从列表中获取数据到ClientPeoplePicker - Sharepoint 2013, get data from list to ClientPeoplePicker 从 Sharepoint 提供程序托管的应用程序中检索 SharePoint 2013 列表数据 - Retrieving SharePoint 2013 List Data from Sharepoint provider hosted app 通过REST从SharePoint 2013中的列表中提取数据 - Pulling data from a list in SharePoint 2013 via REST 使用 Sharepoint Online 2013 从 Sharepoint Webservice 访问列表 - Accessing list from Sharepoint Webservice with Sharepoint Online 2013 通过从xml文件获取数据来更新共享点列表 - update sharepoint list by getting data from xml file C# 从 SharePoint 2013 文档库中检索文档列表 - C# Retrieve Document List From SharePoint 2013 Document Library 如何从FieldLookupValue Sharepoint 2013 CSOM中检索关联的列表名称 - How to retrieve associated list name from a FieldLookupValue Sharepoint 2013 CSOM 迭代sharepoint 2013中的列表 - Iterate through a list in sharepoint 2013 将SharePoint 2013与SSRS报告数据集成,或使用TimerJob将数据从SSRS提取到SharePoint中 - Integrating SharePoint 2013 with SSRS report Data or Extracting Data from SSRS into SharePoint using a TimerJob Azure Function 和 SharePoint webhook:未从 Z97F02F6993B93736DFEZ0D 列表中获取更改 - Azure Function and SharePoint webhook: not getting changes from SharePoint list
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM