微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

从SSIS填充Sharepoint在线列表有效,但不能从Agent Job填充

如何解决从SSIS填充Sharepoint在线列表有效,但不能从Agent Job填充

我每天需要通过 sql Server 2017 表在 SharePoint Online 中的列表中提供大量数据。

我选择通过 sql Server Integration Services 2017 执行此操作,并且它可以正常运行。

为此,我创建了一个名为{em> Package Data flow Task

enter image description here

Data Flow Task中,我已经连接到数据库 DB )以获取数据。

然后,我有一个名为 脚本 Component Script,用于与 Sharepoint Online 建立连接。

然后将数据插入 Sharepoint列表

enter image description here

要与在线共享点建立连接并将数据插入共享点列表,我创建了一些参数:

enter image description here

在组件脚本中,我有以下代码

public override void Input0_ProcessInputRow(Input0Buffer Row)
{
    // Starting with ClientContext,the constructor requires a URL to the
    // server running SharePoint
    string siteUrl = Variables.siteUrl.ToString();

    ClientContext clientContext = new ClientContext(siteUrl);

    // Retrieve Login
    string login = Variables.login.ToString();

    // Retrieve Password
    string password = Variables.password.ToString();

    // Credentials
    clientContext.Credentials = SignIn.Login(login,password);

    // Retrieve List Items
    List myList = clientContext.Web.Lists.GetByTitle(Variables.list.ToString());

    // Create a new ListItemCreationinformation object
    ListItemCreationinformation itemCreateInfo = new ListItemCreationinformation();

    // Create a new List Item 
    ListItem myListItem = myList.AddItem(itemCreateInfo);

    myListItem["Title"] = Row.Name;

    // Note that the web.Update() doesn't trigger a request to the server

    // Requests are only sent to the server from the client library when
    // the ExecuteQuery() method is called
    myListItem.Update();

    // Execute the query to the server
    clientContext.ExecuteQuery();
}

登录 类:

class SignIn
{
    public static SharePointOnlineCredentials Login(string login,string password)
    {
        securestring securePassword = new securestring();

        foreach (char c in password)
        {
            securePassword.AppendChar(c);
        }

        return new SharePointOnlineCredentials(login,securePassword);
    }
}

使用此程序包通过sql Server Agent运行Job时,出现以下错误

用户身份执行:INSTANCE \ sqlAgentService。 Microsoft(R)sql Server 执行64位版权(C)的Package Utility版本12.0.4100.1 微软公司。版权所有。开始时间:14:56:49 错误:2020-09-01 14:58:52.51代码:0x00000001来源:包装 说明:调用的目标已引发异常。 结束错误DTExec:程序包执行返回DTSER_SUCCESS(0)。 开始:14:56:49完成:14:58:52经过:122.735秒。 包成功执行。该步骤成功了。

疑问:

sqlAgentService 是否需要访问 SharePoint Online 的权限?

我是否需要在 sqlAgentService 上安装 Microsoft.SharePoint.Client.Runtime.dll Microsoft.SharePoint.Client.dll dll。 >服务器?

对我来说,身份验证是通过 nameless@test.onmicrosoft.com 帐户进行的(该帐户具有在 SharePoint Online 上进行协作的权限)。

如何通过 sql Server代理填充 Sharepoint在线列表

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。