views:

1392

answers:

8

I am working on project where I have to access SharePoint data in C#.

I've never done this before; and have the following questions?

How would I access SharePoint data from C#? What API do I use? Are there any tutorials out there that will help me get started?

A: 

Start at the Sharepoint SDK page. Download the SDK, and look at the sample code on MSDN.

Added later: according to MS, this is a better site for all things related to Sharepoint development.

Traveling Tech Guy
How is this related to the VS extensions? Are they included?
Robert Harvey
No they are not. I've added another link to my original post with the definitive site for Sharepoint development. You can find more info and download VS extensions for Sharepoint from there.
Traveling Tech Guy
A: 

You have to install VS 2005 or VS 2008 extensions for sharepoint. Intsllaing them on xp can be tricky and this page should hep you with that.

Shoban
Are the VS extensions included in the Sharepoint SDK?
Robert Harvey
AFAIK its not included. The SDK system requirements as for this.
Shoban
You do NOT need the Visual Studio extensions for SharePoint to start coding against the SharePoint API. The extensions exist solely as a packaging tool, and do a rather poor job of that. This is getting world's better for SharePoint/Visual Studio 2010, but for now 3rd party alternatives for building SharePoint deployables (popular ones are WSPBuilder and STSDEV) are held and shoulders above the Microsoft offerings.
OedipusPrime
A: 
Space Cracker
+3  A: 

The SDK is a good place to start. The real crux of question lies in whether you are writing code which will live in a SharePoint environment, or writing code which will consume SharePoint data in an external application.

In the case of the former, SharePoint has its own API which you gain access to by simply referencing the appropriate DLL.

For the latter, SharePoint comes with a set of web services which allow external applications to consume its data. Either these or a set of custom services (running in the SharePoint environment) will be your entry point into SharePoint.

OedipusPrime
A: 

To me it sounds like you should use the Out Of The Box SharePoint web services. There is no reason why you should have to learn the entire SharePoint API when you could get along just talking to the web service.

This primer on InfoQ is good, but do a seach on SharePoint Web Services and you will find plenty of sources

Kasper
+1  A: 

This is how you would do it in PowerShell which is very similar in how you would do it in in C#:

# Lets reference the assembly / GAC that we need for this
function getUsers
{
    param ([string] $verify_sitepath="https://extranet.something.com")
    $verify_site=new-object Microsoft.SharePoint.SPSite($verify_sitepath)
     $verify_web=$verify_site.Rootweb
    $verify_web.site.url
    $verify_groups = $verify_web.groups | ? {$_.Name -match "^.*$CurrentGroup" }
    foreach($verify_group in $verify_groups)
    {
     foreach($verify_user in $verify_group.users)
     {
      $verify_user = $verify_user -replace "WRKGRP\\",""
      Write-Output "$verify_user" | Out-File -filepath "$splist$currentGroup.txt" -append
     }
    }
}

What this does is gets all the users from SharePoint that are in a text file. Hopefully this gets you at least thinking about how SharePoint is set up.

A great resource is the MSDN page with all the functions. They provide a lot of programming samples in C#!

Mitchell Skurnik
+2  A: 

There two ways in which you can access Sharepoint data:

  1. By Using Microsoft.Sharepoint.dll In this case you need to do coding on same machine (windows server).

  2. Second way is to use Sharepoint Web Services. This will allow developer to do developement work on different machine.

Preeti Singh
A: 

i have managed to get sharepoint list data using OLEDB but how can i prevent the username/password prompt?

joel