Hello:

I am attempting to execute the following code which was created with Visual
Studio 2003:

SqlParameter[] DateParameters = new SqlParameter[5];
DateParameters[0] = new SqlParameter("@ConsumerDateID", _dateID);

DateParameters[1] = new SqlParameter("@ConsumerID", Consumer.ConsumerID);

DateParameters[2] = new SqlParameter("@ConsumerDateTypeID", _typeID);

DateParameters[3] = new SqlParameter("@Value", _value);

DateParameters[4] = new SqlParameter("@Index", _index);

I am receiving the following error each time the runtime attempts to store
the DateParameter[3] value (error thrown before next line even reached):

"Index (zero based) must be greater than or equal to zero and less than the
size of the argument list."

I have tried closing and recompiling my code on several occasions, and
altering the size of the array, but cannot get this to execute properly.

Is there an error in my code? Is there some type of IDE or compilation
issue that might be causing this?

Thanks for any insight!

Chris

Re: what's causing this array index error?!?!? by Michael

Michael
Thu Nov 06 09:55:06 CST 2003

Have you tried just copying the SqlParameter construction call from one of
the first 3 that work over the one that's failing, just to make sure the
error isn't in that somewhere? The assignment statements look fine...


"ChrisB" <pleasereplytogroup@thanks.com> wrote in message
news:eXyqkzEpDHA.2772@TK2MSFTNGP12.phx.gbl...
> Hello:
>
> I am attempting to execute the following code which was created with
Visual
> Studio 2003:
>
> SqlParameter[] DateParameters = new SqlParameter[5];
> DateParameters[0] = new SqlParameter("@ConsumerDateID", _dateID);
>
> DateParameters[1] = new SqlParameter("@ConsumerID", Consumer.ConsumerID);
>
> DateParameters[2] = new SqlParameter("@ConsumerDateTypeID", _typeID);
>
> DateParameters[3] = new SqlParameter("@Value", _value);
>
> DateParameters[4] = new SqlParameter("@Index", _index);
>
> I am receiving the following error each time the runtime attempts to store
> the DateParameter[3] value (error thrown before next line even reached):
>
> "Index (zero based) must be greater than or equal to zero and less than
the
> size of the argument list."
>
> I have tried closing and recompiling my code on several occasions, and
> altering the size of the array, but cannot get this to execute properly.
>
> Is there an error in my code? Is there some type of IDE or compilation
> issue that might be causing this?
>
> Thanks for any insight!
>
> Chris
>
>



Re: what's causing this array index error?!?!? by Girish

Girish
Thu Nov 06 10:12:26 CST 2003

ChrisB wrote:

> Hello:
>
> I am attempting to execute the following code which was created with Visual
> Studio 2003:
>
> SqlParameter[] DateParameters = new SqlParameter[5];
> DateParameters[0] = new SqlParameter("@ConsumerDateID", _dateID);
>
> DateParameters[1] = new SqlParameter("@ConsumerID", Consumer.ConsumerID);
>
> DateParameters[2] = new SqlParameter("@ConsumerDateTypeID", _typeID);
>
> DateParameters[3] = new SqlParameter("@Value", _value);
>
> DateParameters[4] = new SqlParameter("@Index", _index);
>
> I am receiving the following error each time the runtime attempts to store
> the DateParameter[3] value (error thrown before next line even reached):
>
> "Index (zero based) must be greater than or equal to zero and less than the
> size of the argument list."
>
> I have tried closing and recompiling my code on several occasions, and
> altering the size of the array, but cannot get this to execute properly.
>
> Is there an error in my code? Is there some type of IDE or compilation
> issue that might be causing this?
>
> Thanks for any insight!
>
> Chris
>
>


Well, Is this a a stored proceudre that you are trying to call? If yes,
you might want to show the stored procedure as well. I think the first
one is the RETURNVALUE from the stored procedure.. And, make sure that
its hitting the stored procedure that you think it should be hitting. :)

--
Girish Bharadwaj


Re: what's causing this array index error?!?!? by ChrisB

ChrisB
Thu Nov 06 13:34:56 CST 2003

Thanks for the input Michael and Girish.

After spending some more time reviewing this code, I determined that the
problem was related to the fact that
_value contains an object (not a string).

The related line of code had to be changed to
DateParameters[3] = new SqlParameter("@Value", _value.date);

The index error message being thrown made debugging this a little confusing!

Thanks again.

Chris

"ChrisB" <pleasereplytogroup@thanks.com> wrote in message
news:eXyqkzEpDHA.2772@TK2MSFTNGP12.phx.gbl...
> Hello:
>
> I am attempting to execute the following code which was created with
Visual
> Studio 2003:
>
> SqlParameter[] DateParameters = new SqlParameter[5];
> DateParameters[0] = new SqlParameter("@ConsumerDateID", _dateID);
>
> DateParameters[1] = new SqlParameter("@ConsumerID", Consumer.ConsumerID);
>
> DateParameters[2] = new SqlParameter("@ConsumerDateTypeID", _typeID);
>
> DateParameters[3] = new SqlParameter("@Value", _value);
>
> DateParameters[4] = new SqlParameter("@Index", _index);
>
> I am receiving the following error each time the runtime attempts to store
> the DateParameter[3] value (error thrown before next line even reached):
>
> "Index (zero based) must be greater than or equal to zero and less than
the
> size of the argument list."
>
> I have tried closing and recompiling my code on several occasions, and
> altering the size of the array, but cannot get this to execute properly.
>
> Is there an error in my code? Is there some type of IDE or compilation
> issue that might be causing this?
>
> Thanks for any insight!
>
> Chris
>
>