I have simple script :
public void Main()
{
// TODO: Add your code here
Dts.TaskResult = (int)ScriptResults.Success;
//MYCode
Variables varCollection = null;
string DestinationRoot = varCollection("User::DestinationRoot").Value.ToString();
int MonthStartPosition = Convert.ToInt32(varCollection("User::MonthStartPosition").Value);
int MonthLength = Convert.ToInt32(varCollection("User::MonthLength").Value);
int MonthValue = 0;
string MonthNameFormat = varCollection("User::MonthNameFormat").Value.ToString();
string FolderName = string.Empty;
string MonthwiseDirectory = string.Empty;
if (MonthStartPosition > 0 && MonthLength > 0)
{
MonthValue = Convert.ToInt32(FileName.Substring(MonthStartPosition - 1, MonthLength));
}
if (FileName.Length > 0 && MonthValue > 0)
{
FolderName = new DateTime(1, MonthValue, 1).ToString(MonthNameFormat);
}
MonthwiseDirectory = System.IO.Path.Combine(DestinationRoot, FolderName);
if (!System.IO.Directory.Exists(MonthwiseDirectory))
{
System.IO.Directory.CreateDirectory(MonthwiseDirectory);
}
varCollection("User::DestinationFolder").Value = MonthwiseDirectory;
//Error 1 : also getting error here like 'varCollection' is a 'variable' but is used like a 'method'
Dts.TaskResult = Dts.Results.Success; //Error 2
}
But it gives error like :
Error 1 : 'varCollection' is a 'variable' but is used like a 'method'
Error 2: 'Microsoft.SqlServer.Dts.Tasks.ScriptTask.ScriptObjectModel' does not contain a definition for 'Results' and no extension method 'Results' accepting a first argument of type 'Microsoft.SqlServer.Dts.Tasks.ScriptTask.ScriptObjectModel' could be found (are you missing a using directive or an assembly reference?) C:\Users\AppData\Local\Temp\SSIS\dfac06a62ee9472bac783737af4957de\ScriptMain.cs 91 34 st_7c1dde41280d4efc996c50fead62bfa9