SharePoint via Web Service- GetList items and build SQL tabl

本文关键字:and build SQL tabl items GetList via Web Service- SharePoint | 更新日期: 2023-09-27 18:35:02

Scenraio:我无权在与SharePoint相同的服务器上运行该程序。我只能访问到 SharePoint 服务器 URL。因此,我选择使用 Web 引用访问 SharePoint 服务来访问 SharePoint 2010 列表。

这是我的代码

using System;
using System.Net;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
namespace SPTechOpsProjectTracker
{
    class Program
 {
    static void Main(string[] args)
    {
        //Add a reference to my web service
        TechOpsProjectWebService.Lists listService = new TechOpsProjectWebService.Lists();
        //use the logged in user’s credentials
        listService.Credentials = System.Net.CredentialCache.DefaultCredentials;
        String listGUID = "a486016e-80b2-44c3-8b4a-8394574b9430";
        String activeItemViewGUID = "60689d51-5787-4ef1-9515-c050f20fa424 ";
        //calling the GetListItems service to return the 1000 list items 
        //for theparticular list and view that you pass to the function
        System.Xml.XmlNode activeItemData = listService.GetListItems(listGUID, activeItemViewGUID, null, null, "1000", null, "");
        // Go through the list to see what was returned
    foreach(System.Xml.XmlNode listItem in activeItemData) 
    {
     // Get the attributes
     System.Xml.XmlAttributeCollection attrs = listItem.Attributes;
     Console.WriteLine(listItem.OuterXml);
     Console.WriteLine("Press any key to continue"); 
     Console.ReadLine();
    }
     //connect to my SQL server 2008 server
     //Create a database
     //Create a table in that database.
     //Dump the values of attributes obtained from my code to that table.

    }
   }
}

问题:我需要连接到我的 SQL 服务器 2008 服务器创建数据库在该数据库中创建一个表。将从我的代码中获取的属性值转储到该表中。

非常感谢您的帮助/建议。谢谢。

SharePoint via Web Service- GetList items and build SQL tabl

看看这个,一个通过 C# 连接到 SQL Server 的指南。

问候!