Link to home
Start Free TrialLog in
Avatar of paultran00
paultran00Flag for United States of America

asked on

LOG file, creating an SSIS package and a script in c#.net

Hi,

I'm using Visual Studio 2017 and Azure SQL Server 2016.  I'm creating an SSIS package and a script in c#.net

QUESTION:
1. My ReadOnlyVariables = System::StartTime
2. In my script Task, how do I get the value of System::StartTime?
3. how do I format datetime to yyyymmdd_hhmm
4. I want to write this information to a LOG file.  If the app1.LOG NOT exist, then create a log file (E.G., DATESTAMP + ' package kickoff'), else append data to it (E.G., datestamp + 'package completed'.
5. My WriteVariables = User:varFolderName.    in my script task, how do I assign a value to to varFolderName ?

What is the code to do this?  Thanks.
Avatar of Arifhusen Ansari
Arifhusen Ansari
Flag of India image

Hello paultran00,


Accessing variable is same whether you read or write data in variable.

But pass variable to respective mode. If you want to read that variable pass in "ReadOnlyVariable" if you want to write data in variable you have to pass it in "ReadWriteVariables". Refer attached screenshot.User generated image.

Below is the syntax how to read variable data in Script task.

Dts.Variables["User::SourceFolder"].Value.ToString()

Open in new window


User generated image
I have used "User" variable so "User" is used. You can use "System" in you case.

To write data in variable
Dts.Variables["User::SourceFolder"].Value="XYZ"

Open in new window


Hope it will help
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.