I need help with some C# code. I have build a SSIS package with an Execute Process Task. I need to send dynamic variables in to my C# program so I thought it was a good idea to use the StandardInputVariable.
How do I get the variable in my C# code?
Thanks
CarlYour Main methods parameter collection?|||
yes. provided that this functionality has been built into the c# code.|||Thanks for your help.Peter K wrote: Your Main methods parameter collection?
I tried to get the variable through the main method but it dont work, the only thing I got was the argument.
My test code:
static void Main(string[] args)
{
for (int i=0; i<args.Length; i++)
{
Console.WriteLine(args);
Console.ReadLine();
}
Carl|||
did you include the variable as an argument to your c# executable in the execute process task?|||I have a static argument and a variable in StandardInputVarable. I put a value in the variable for testing but it will be dynamic.|||ctsand wrote: Thanks for your help. I tried to get the variable through the main method but it dont work, the only thing I got was the argument.
My test code:
static void Main(string[] args)
{
for (int i=0; i<args.Length; i++)
{
Console.WriteLine(args);
Console.ReadLine();
}Carl
is this necessary? can't you just use a dynamically updated ssis variable when calling your executable in the execute process task?|||ctsand wrote: I have a static argument and a variable in StandardInputVarable. I put a value in the variable for testing but it will be dynamic.
My intention was have to have the argument to jump to a special method in the code. The variable will have information about witch rows in the table the code shall read in and treat.
In any case, can I put a dynamic variable in the argument?
Carl
|||the code below is how to execute package in c# code.the red code tell you how to dymamic edit variable.i think this method can get variable.but i didn't try.please try it
//add reference "Microsoft.SqlServer.ManagedDTS"(in microsoft.sqlserver.manageddts.dll)
Imports Microsoft.SqlServer.Dts.Runtime
Dim pkg As String = "package directory"
Dim app As Application = New Application()
Dim p As Pakage = app.LoadPackage( pkg, Nothing )
p.InteractiveMode = true
Dim pty As DtsProperty
'Dim n As Integer = p.Configurations.Count
Dim strPty As String
For Each pty In p.Properties
strPty = pty.Name & ":"
Try
If pty.Get Then strPty &= pty.GetValue( pty ).ToString()
Catch
End Try
Console.WriteLine( strPty )
Next
Dim vir As Variables = p.Variables
vir( "strFile" ).Value = "C:\MyApp2.txt"
Console.WriteLine( p.Execute( Noting, vir, Nothing, Nothing, Nothing ).ToString() )
|||
understoodctsand wrote: My intention was have to have the argument to jump to a special method in the code. The variable will have information about witch rows in the table the code shall read in and treat.
i don't know. did you try?|||In any case, can I put a dynamic variable in the argument? Carl
I tried it but it didnt worked. The only thing I got was the name of the variable.
You wrote earlier:
is this necessary? can't you just use a dynamically updated ssis variable when calling your executable in the execute process task?
What did you mean by that?
|||what are the option settings in the process page of the execute process task editor?|||ctsand wrote: I tried it but it didnt worked. The only thing I got was the name of the variable.
You wrote earlier:
is this necessary? can't you just use a dynamically updated ssis variable when calling your executable in the execute process task?
What did you mean by that?
RequireFullFileName = True
Executable = M:\Program\Person.exe
Arguments = fakt
WorkingDirectory = M:\Program
StandardInputVariable = User::test
StandardOutputVariable =
StandardErrorVariable =
FailTaskIfReturnCodeIsNotSuccessValue = True
SuccessValue = 0
TimeOut = 0
TerminateProcessAfterTimeOut = True
WindowStyle = Normal
|||what is the value and data type of User::test immediately before the execute process task starts executing? is the value of this variable correct?|||The data type is string and the value is testing.
I have a question for you.
Is't meaning that I shall use the main-method to get the argument and the variable?
Carl
No comments:
Post a Comment