The main difference is handling variable in terms of syntax. In C# you need to use brackets, not parentheses so instead of the top line of code, you need to use the bottom one
Dts.Variables(“varFileName”).Value
Dts.Variables["varFileName"].Value
Dts.Variables["varFileName"].Value
Here is the code block in C#
string FileName;
FileName = Dts.Variables["varFileName"].Value.ToString();
MessageBox.Show(FileName);
MessageBox.Show(FileName);
One more example:
C#
public void Main()
{
if(Dts.Variables.Contains("User::MyValue"))
{
System.Windows.Forms.MessageBox.Show("MyValue=" +
if(Dts.Variables.Contains("User::MyValue"))
{
System.Windows.Forms.MessageBox.Show("MyValue=" +
Dts.Variables["User::MyValue"].Value.ToString());
}
Dts.TaskResult = (int)ScriptResults.Success;
}
Dts.TaskResult = (int)ScriptResults.Success;
}
VB
Public Sub Main()
If Dts.Variables.Contains("User::MyValue") = True Then
System.Windows.Forms.MessageBox.Show("myValue=" &
Dts.Variables("User::MyValue").Value.ToString())
End If
Dts.TaskResult = ScriptResults.Success
End Sub
Cheers!
Uma
Uma
No comments:
Post a Comment