T
Tim Zych
' Declare a new parameter object
Dim param() As SqlParameter = New SqlParameter(0) {}
' Set this to null and make it an InputOutput parameter
param(0) = New SqlParameter("@Something, DBNull.Value) ' Can also be
non-null, but sometimes is null
param(0).Direction = ParameterDirection.InputOutput
' But, before we begin, store a copy of the existing parameters into another
variable
Dim param2() As SqlParameter = New SqlParameter(0) {}
param2 = param
' Run the stored proc. The stored proc has an OUTPUT parameter which will
return a value to the caller
SqlHelper.ExecuteNonQuery("ConnStr", CommandType.StoredProcedure,
"dbo.MyStoredProc, param)
WHERE
MyStoredProc's @Something parameter is an OUTPUT parameter, and after the
stored proc is finished running, BOTH SqlParameters have the same value.
It looks like "param2 = param" is a reference copy. How can I copy by value
only so that, when the Output argument returns a value to the first
parameter, param2 does NOT have the same value. I want a value copy, not a
reference copy. How do I do that?
Dim param() As SqlParameter = New SqlParameter(0) {}
' Set this to null and make it an InputOutput parameter
param(0) = New SqlParameter("@Something, DBNull.Value) ' Can also be
non-null, but sometimes is null
param(0).Direction = ParameterDirection.InputOutput
' But, before we begin, store a copy of the existing parameters into another
variable
Dim param2() As SqlParameter = New SqlParameter(0) {}
param2 = param
' Run the stored proc. The stored proc has an OUTPUT parameter which will
return a value to the caller
SqlHelper.ExecuteNonQuery("ConnStr", CommandType.StoredProcedure,
"dbo.MyStoredProc, param)
WHERE
MyStoredProc's @Something parameter is an OUTPUT parameter, and after the
stored proc is finished running, BOTH SqlParameters have the same value.
It looks like "param2 = param" is a reference copy. How can I copy by value
only so that, when the Output argument returns a value to the first
parameter, param2 does NOT have the same value. I want a value copy, not a
reference copy. How do I do that?