简体   繁体   English

在SSIS中的脚本任务编辑器中出现错误

[英]Getting error in Script Task Editor in SSIS

I am trying to upgrade SSIS package from 2013 to 2017. But, I am getting error for the below lines of code. 我正在尝试将SSIS软件包从2013年升级到2017年。但是,以下代码行出现错误。 Can anyone please resolve this? 谁能解决这个问题?

I am new so I haven't tried anything yet. 我是新手,所以还没有尝试任何东西。

using System;
namespace ST_3e6cc55d375c472785d01c446ea4bf8b
{
    [Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute]
    public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
    {
        public object Now { get; private set; }

        enum ScriptResults
        {
            Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
            Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure

        };

        public void Main()
        {
            // TODO: Add your code here
            Dts.Variables("FileNameCSV").Value = Format(Now, "yyyyMMddHHmmss") + "_MailPieces_" + LTrim(RTrim(Dts.Variables("FrequencyType").Value)) + ".csv";
            Dts.Variables("FileNameZIP").Value = Format(Now, "yyyyMMddHHmmss") + "_MailPieces_" + LTrim(RTrim(Dts.Variables("FrequencyType").Value)) + ".zip";

            Dts.TaskResult = (int)ScriptResults.Success;
        }
    }
}

I am getting these below errors. 我得到这些下面的错误。 Please help. 请帮忙。

Error CS1955 Non-invocable member 'ScriptObjectModel.Variables' cannot be used like a method. 错误CS1955不可使用的成员'ScriptObjectModel.Variables'不能像方法一样使用。

Error CS0103 The name 'Format' does not exist in the current context 错误CS0103当前上下文中不存在名称“格式”

Error CS0103 The name 'LTrim' does not exist in the current context 错误CS0103在当前上下文中名称'LTrim'不存在

Error CS0103 The name 'RTrim' does not exist in the current context 错误CS0103当前上下文中不存在名称“ RTrim”

Three suggestions: 三点建议:

  1. Replace Now with DateTime.Now NowDateTime.Now替换
  2. Use ToString(<format>) instead of Format() 使用ToString(<format>)代替Format()
  3. Use Trim() instead of LTrim(RTrim()) 使用Trim()而不是LTrim(RTrim())

Try using the following code: 尝试使用以下代码:

using System;
namespace ST_3e6cc55d375c472785d01c446ea4bf8b
{
    [Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute]
    public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
    {


        enum ScriptResults
        {
            Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
            Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure

        };

        public void Main()
        {
            // TODO: Add your code here
            Dts.Variables("FileNameCSV").Value = DateTime.Now.ToString("yyyyMMddHHmmss") + "_MailPieces_" + Dts.Variables("FrequencyType").Value.ToString().Trim() + ".csv";
            Dts.Variables("FileNameZIP").Value = DateTime.Now.ToString("yyyyMMddHHmmss") + "_MailPieces_" + Dts.Variables("FrequencyType").Value.ToString().Trim() + ".zip";

            Dts.TaskResult = (int)ScriptResults.Success;
        }
    }
}

Looks like you're missing the reference to DTS runtime assembly. 似乎您缺少对DTS运行时程序集的引用。 Try adding this to your using block: 尝试将其添加到您的using块:

using Microsoft.SqlServer.Dts.Runtime; 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM