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

Cannot load script for execution.

$
0
0

hi 

 iam creating  the  sisi package  with in script task . script task   was  build successful .  but when i was executive the ssis packages vs 2012.

 it get  error :Cannot load script for execution..

 the code is 

/*
   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;
using System.IO;



namespace ST_8cdbf584a74b48abb384d8f03cf42f4d.csproj
{
    
    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()
        {
            byte[] dataByte = null; String errInfo = "";
            try
            {
                String sDirectory = Dts.Variables["User::Directory"].Value.ToString();
                String CreatePartitionFileXMLA = sDirectory + "\\partitionssales20010701to20010731.XMLA";
                String ProcessPartitionFileXMLA = sDirectory + "\\partitionssales20010701to20010731.XMLA";
                // Create XMLA Script
                Dts.Variables["User::CreatePartitions"].Value = ReadFile(CreatePartitionFileXMLA, errInfo);
                if (errInfo.Length > 0)
                {
                    Dts.Log("Error while reading XMLA file: " + errInfo, 0, dataByte);
                    Dts.TaskResult = (int)ScriptResults.Failure;
                }
                //Process XMLA Script
                Dts.Variables["User::ProcessPartitions"].Value = ReadFile(ProcessPartitionFileXMLA, errInfo);
                if (errInfo.Length > 0)
                {
                    Dts.Log("Error while reading XMLA file: " + errInfo, 0, dataByte);
                    Dts.TaskResult = (int)ScriptResults.Failure;
                }
                Dts.TaskResult = (int)ScriptResults.Success;
            }
            catch (Exception ex)
            {
                Dts.Log("Error Message: " + ex.Message, 0, dataByte);
                Dts.TaskResult = (int)ScriptResults.Failure;
            }
        }

        public String ReadFile(String FilePath, String ErrInfo)
        {
            String strContents;
            StreamReader sReader;
            try
            {
                sReader = File.OpenText(FilePath);
                strContents = sReader.ReadToEnd();
                sReader.Close();
                return strContents;
            }
            catch (Exception e)
            {
                MessageBox.Show(ErrInfo);
                ErrInfo = e.Message;
                return "";
            }
        }
    }
}

 how to solve this issue

 pleasse help me..

 


Viewing all articles
Browse latest Browse all 24688

Trending Articles



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