Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

SSIS Script Requires Migration

$
0
0

Hello, folks!

Yesterday, I ran an SSIS package that has been working flawlessly in VS2008. But, when I try to run it in VS2013, I get the following warning;

Found SQL Server Integration Services 2008 Script Task "[insert task ID here]" that requires migration!

I've looked over the script and can't see what may be the problem. For your assistance, I will post it below;

/*
   Microsoft SQL Server Integration Services Script Task
   Write scripts using Microsoft Visual C# 2008.
   The ScriptMain is the entry point class of the script.
*/

using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;

namespace ST_1276eec7c49c484a9baf0e534b3e18ac.csproj
{
    [System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
    public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
    {

        #region VSTA generated code
        enum ScriptResults
        {
            Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
            Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
        };
        #endregion

        /*
		The execution engine calls this method when the task executes.
		To access the object model, use the Dts property. Connections, variables, events,
		and logging features are available as members of the Dts property as shown in the following examples.

		To reference a variable, call Dts.Variables["MyCaseSensitiveVariableName"].Value;
		To post a log entry, call Dts.Log("This is my log text", 999, null);
		To fire an event, call Dts.Events.FireInformation(99, "test", "hit the help message", "", 0, true);

		To use the connections collection use something like the following:
		ConnectionManager cm = Dts.Connections.Add("OLEDB");
		cm.ConnectionString = "Data Source=localhost;Initial Catalog=AdventureWorks;Provider=SQLNCLI10;Integrated Security=SSPI;Auto Translate=False;";

		Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.

		To open Help, press F1.
	*/

        public void Main()
        {
            // TODO: Add your code here
            string[] files = System.IO.Directory.GetFiles(@"\\Path\", "Filename *.xlsx");
            string oldestFileName = string.Empty;
            DateTime oldestDate = DateTime.MaxValue;
            foreach (string file in files)
            {
                string fileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(file);
                string datepart = fileNameWithoutExtension.Substring(fileNameWithoutExtension.Length - 10);
                string convdate = datepart.Substring(0, 4) + datepart.Substring(5, 2) + datepart.Substring(8, 2);
                DateTime dt = DateTime.ParseExact(convdate, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture);
                if (dt < oldestDate)
                {
                    oldestFileName = file;
                    oldestDate = dt;
                }
            }

            Dts.Variables["User::Variable"].Value = oldestFileName;
            Dts.TaskResult = (int)ScriptResults.Success;
        }
    }
}

All this code does is grab the date of an imported Excel file from the file's filename. Doesn't seem to be all that big a deal.

I see where the script says "Microsoft Visual C# 2008" in the leading comments, but it is - well - a comment, not something executable.

All I can think of is that, perhaps, the C# code compiler has changed for VS2013 and that there might be a command that is not compatible, but I don't know.

Any ideas out there?

Thanx!



Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>