How do you Read SharePoint Lists Programmatically?

19,751

Solution 1

You have several options both of which are going to require further research on your part they are:

  1. Use the SharePoint object model (Microsoft.Sharepoint.dll), you must be on a PC within the SharePoint farm.
  2. Use the SharePoint web services which can be found at SiteURL/_vti_bin/ you might want to start with Lists.asmx and work from there.

You are going to need some further research as I have said, but remember GIYF.

Solution 2

I would really encourage everyone on this topic to have a look at the ado.net driver for sharepoint from bendsoft.com. It is free for developers to use and allows you to query sharepoint information using standard sql syntax and takes care of all sorts of conversion for you.

Dim conn As New SharePointConnection("Server=mysharepointserver.com;Database=sitepath;User=spuser;Password=******;")
conn.Open()
Dim cmd As New SharePointCommand("UPDATE Employees SET Salary = 3250.50 WHERE Name = 'Steve Watson'", conn)
cmd.ExecuteNonQuery()
Share:
19,751

Related videos on Youtube

Ric Tokyo
Author by

Ric Tokyo

Mostly doing fulltime: C#, WPF, WinForms, SharePoint MOSS, ASP.NET, SQL Server 2005/2008, Linux, Windows, etc

Updated on April 19, 2022

Comments

  • Ric Tokyo
    Ric Tokyo about 2 years

    I currently use the Linq to SharePoint to retrieve data from several SharePoint lists.

    This is my current preferred method of coding my way from ASP.NET and WinForms to retrieve this data.

    My only issue with this project:

    I have to manually generate the SPML file and add this to the development environment, compile it in the project, and only then I am able to use it to connect to the List.

    This is great for projects that require connecting to the one and the same list always.

    But I am having users creating new workspaces (sites) with each its own List from which I want to retrieve data automagically (same as linq to sharepoint does, but not statically).

    Can you recommend your preferred way of accessing data from several SharePoint Lists and sites in C# WinForms and/or ASP.NET outside an actual SharePoint environment where I can specify the a new source site and list at run time?

  • Ric Tokyo
    Ric Tokyo about 15 years
    +1 thank you for the input. One point though: it is possible to use the SharePoint Object Model outside the SharePoint Farm (its how I currently use Linq to SharePoint)
  • andriy
    andriy over 12 years
    Point #1 is what kills me about SharePoint. Just imagine being told that in order to retrieve information from SQL Server, you must develop your code on the same server as the SQL Server instance.
  • HiTech
    HiTech over 7 years
    Doesn't look like this is free anymore.