views:

156

answers:

1

I'm having a problem OUTPUTing a variable in my assembly.

  1. Do I need to add a "out string var1" to the parameter list of the function in C#? I get an error - something related to var1 not being set...
  2. I tried parameter.Direction = ParameterDirection.Output
  3. I can't find any good examples

Edit: My assembly SP currently returns a recordset.... I want it to OUTPUT some variables so that I can use them in another SP where this is called from

I.E.

DECLARE @var1 int
EXEC dbo.MyAssemblySP @var1 OUTPUT
PRINT @var1
+1  A: 

Not quite sure what you are trying to do, but if you are trying to use the "out" keyword, here is the proper syntax:

public void foo(int arg1, out int arg2) { arg2 = arg1; }

public void foo2() { int aOutput; foo(1, out aOutput); Console.WriteLine(aOutput); }

Calling foo2 will result in the console writing "1".

Bill