471,348 Members | 1,714 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,348 software developers and data experts.

create dynamic object[]

Hi,
Does anyone know how to do it? I have an oCommandWrapper that has an
input paramater{{"@registrationId",DbType.String,strRegC ode}} 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())};
}

Jan 13 '06 #1
1 1689
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[i].Direction == ParameterDirection.Output ||
command.Param... == ParameterDirection.InputOutput)
{
paramList.Add(command.Parameter[i].Value);
}
}
return paramList.ToArray();
}

This is the method I use to get the output parameter values.
Jan 13 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by RSB | last post: by
1 post views Thread by Tom | last post: by
reply views Thread by Pascal Costanza | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.