473,322 Members | 1,421 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

unusual array error at runtime

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
Nov 15 '05 #1
2 1104
ChrisB <pl****************@thanks.com> wrote:
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?


Could you post a short but complete program which demonstrates the
problem? It sounds very odd to me.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #2
Jon:

I created a small application to demonsrate the issue as you requested, but
was unable to recreate the error.

After reviewing the code a bit longer, I was able to determine the source of
the problem:

_value contains an object, not a string and had to be changed to _value.date

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

// changed code
DateParameters[3] = new SqlParameter("@Value", _value.date);

Seems obvious now, but the index error message threw me off quite a bit (my
head is a little sore from banging it against the wall :>) ).

Oh well, live and learn!

Thanks for offering your help.

Chris
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
ChrisB <pl****************@thanks.com> wrote:
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?


Could you post a short but complete program which demonstrates the
problem? It sounds very odd to me.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jennifer Palonus | last post by:
One of our customers reported a strange problem with our app, running on Win2003 Server: We have two VC++6 (classic C++) .exe's that talk to each other - an MFC app talking to a COM server....
1
by: Jonathan Amend | last post by:
I'm trying to port some C++ code to VB.NET but I have hit a snag. I need to add the pointer of a structure which includes an array to an array and then pass it to an API. Here are the two code...
3
by: Ben | last post by:
Hi I am creating a dynamic function to return a two dimensional array from a delimeted string. The delimited string is like: field1...field2...field3... field1...field2...field3......
9
by: mupe | last post by:
Hi, i have a problem with a Type Library, which is written in C++. I am developing an application in C#.NET and have to use functions from this COM-Type Library. When I use these functions in...
3
by: raylopez99 | last post by:
Hi all, I'm getting a runtime error for the below program, though it compiles fine. The culprit seems to be the managed array--it doesn't exist. What am I doing wrong? RL //...
5
by: mikes1962 | last post by:
I am developing a Dialog based application using visual c++ .net 2003 running on XP, and when I run I periodically get the following error message. "The application has requested runtime to...
7
by: brett.estabrook | last post by:
I have written a multi-threaded c# windows service in .net 1.1 (Visual Studio .net 2003). The service has several threads that poll a Sql 6.5 database on another machine. Each thread will execute a...
3
by: raylopez99 | last post by:
Below is my problem. I've narrowed it down to one thing: my unfamiliarity on how class instances are instantiated in an array. This is because the "un-array" / "non-array" version of the program...
5
by: =?Utf-8?B?QXlrdXQgRXJnaW4=?= | last post by:
Hi Willy, Thank you very much for your work. C++ code doesnot make any serialization. So at runtime C# code gives an serialization error at "msg_file_s sa = (msg_file_s) bf.Deserialize(ms);"...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.