create dynamic object[]

  • Thread starter Thread starter androidsun
  • Start date Start date
A

androidsun

Hi,
Does anyone know how to do it? I have an oCommandWrapper that has an
input paramater{{"@registrationId",DbType.String,strRegCode}} and two
output paramerters {{"@strSessionTime",DbType.DateTime,8},
{"@strCourseName",DbType.String,200}}. The
db.ExecuteNonQuery(oCommandWrapper) is successfully executed. I am
trying to use the following code to retrieve the output values and put
them in aryRtnParams which is an object[]. So far I could only get the
last value out, due to the aryRtnParams is reinitialized at every loop.

for (byte byteThisPos=0; byteThisPos < aryOut.Length; byteThisPos++)
{
object[] aryParamStruct = (object[])aryOut[byteThisPos];
aryRtnParams = new
object[]{oCommandWrapper.GetParameterValue(aryParamStruct[0].ToString())};
}

When I tried the following code, I got an error of
"System.NullReferenceException Object reference not set to an instance
of an object".
for (byte byteThisPos=0; byteThisPos < aryOut.Length; byteThisPos++)
{
object[] aryParamStruct = (object[])aryOut[byteThisPos];
aryRtnParams[byteThisPos] = new
object[]{oCommandWrapper.GetParameterValue(aryParamStruct[0].ToString())};
}
 
Hello,
I am
trying to use the following code to retrieve the output values and put
them in aryRtnParams which is an object[].

Why not trying this:

function getOutputParameterArray()
{
ArrayList paramList = new ArrayList();
for (int i = 0; i < command.Parameters.Count; i++)
{
if (command.Parameters.Direction == ParameterDirection.Output ||
command.Param... == ParameterDirection.InputOutput)
{
paramList.Add(command.Parameter.Value);
}
}
return paramList.ToArray();
}

This is the method I use to get the output parameter values.
 
Back
Top