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

C# Scripting: Not returning/assigning value to variable

$
0
0

Hi,

I'm not getting returned value from the following code.

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

namespace ST_54c2b069e2f34b67b156d4384eea2e5b.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


        public void Main()
        {
            bool tmsg = true;
            bool fmsg = false;
            string FPath = Path.Combine("FilePath", "DrgFileName");

            try
            {

                if (System.IO.File.Exists(FPath))
                {
                    Dts.Variables["bolFileExists"].Value = tmsg;
                }
                else
                    Dts.Variables["bolFileExists"].Value = fmsg;

            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
            Dts.TaskResult = (int)ScriptResults.Success;
        }
    }
}

Note:

FilePath value is C:\Test\ 

and DrgFileName value is test.txt 

bolFileExists is boolean variable that i want to assign value if file exists then its true else it should assign false.

Thanks in advance!

 

ZK


Viewing all articles
Browse latest Browse all 24688

Trending Articles



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