views:

440

answers:

3

I have a SharePoint list already created. I would like to occassionally update that list using a .NET application. How would I do that?

EDIT: This has to run on remote machines.

+1  A: 

Assuming you have your siteId and webId you can do something like this:

using (SPSite site = new SPSite(siteId))
{
    SPWeb web = site.OpenWeb(webId);
    SPList list = web.Lists["ListName"];

    // Manipulate your SPList here
}
pgb
I think you would also want to use `using` around the `OpenWeb` call.
Chris Farmer
+2  A: 

pgb's answer is correct. It's pretty simple, really. One caveat with this is that the code that uses the SharePoint object model must be running on the SharePoint server itself -- not a remote machine. If you're trying to interact with a SharePoint list remotely, you would probably want to use web services. SharePoint 2007 has decent coverage of list manipulation in its built-in web services, but if you want more specific functionality you can always roll your own.

A good starting point for the roll-your-own option is here: http://msdn.microsoft.com/en-us/library/ms464040.aspx

The SDK docs for the Lists web service can be found at http://msdn.microsoft.com/en-us/library/lists.aspx

Chris Farmer
Unfortunately running on the server isn't a viable option. Do you have more info one the built-in web services?
Jonathan Allen