Reputation: 25
I'm not sure why this happens, but my script task is not storing a DateTime-Value in a variable. This is the (till now) very basic code I've written:
[Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute]
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
{
public void Main()
{
DateTime creationTime;
DateTime modifiedTime;
DateTime oldCreationDate = (DateTime)Dts.Variables["User::OldFileDate"].Value;
DateTime oldModifiedTime = (DateTime)Dts.Variables["User::OldModifiedDate"].Value;
Dts.Variables["User::OldFileDate"].Value = DateTime.Now;
Dts.TaskResult = (int)ScriptResults.Success;
}
enum ScriptResults
{
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
};
}
It's not done yet, but I wanted to check if the variable is stored or not. I checked the variables using the debugger, during runtime the varible changes, but if I look at the variable after the execution it is still the same value.
I also checked the properties and ReadOnly
is False
and the Variables are also added to the package.
Any Ideas on what I am doing wrong?
Upvotes: 0
Views: 8262
Reputation: 3993
Once stopped at a breakpoint, look at your variables in the watch window for run time values. The variable window is not updated during debugging.
EDIT: Based on your comment ignore the above. You can save the variable at any time in your package including the end. I suggest that you use an execute SQL task to:
Insert Into ImportedFiles (FileName, Imported) Values (?, getdate())
Based on comments to your question you want to determine if the file was imported previously. You can do:
Select 1 From ImportedFiles Where FileName = ?
Then based on that query you can set up logic to either import the file or skip it.
Upvotes: 1