MSSQL 2005 C# Assembly & output
-
03-07-2019 - |
Question
I'm having a problem outputting a variable in my assembly.
- Do I need to add a
out string var1
to the parameter list of the function in C#? I get an error - something related tovar1
not being set... - I tried
parameter.Direction = ParameterDirection.Output
- 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
Solution
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
.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow