473,320 Members | 2,052 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,320 software developers and data experts.

More of "Index was outside the bounds of the array"

Herfried and Cor:-

I used tracing and actually tracked down the code that was causing the
problem most likely. I wonder if you wanted to comment on it.

Also I wonder if there is a better way of testing if there is data than
testing the length of the xml string I used as stringreader to create the
dataset, but thats a side issue.

I think I tried isdbnull and is nothing and stuff like that and they cause
run time errors if there isnt any data, in other areas of code I have had
problems with using it so found this a reasonable way of ensuring the string
returned with data that must mean there was data - as I have a catch anyway
so if any errors occur, it will quit before it gets to these string length
testing parts of code.

Anyway back to the actual problem. I THINK its because the application
usually throws a comma in the field1, but I can reproduce the error if I
don't.
I THINK I either need to change my selection of fields (and get less
complicated and get data from seperate fields that might contain same data )
or test for an index of comma in the file, and do something different if
there is no comma.

If Len(xmlstr1) > 25 Then
For intCounter = 0 To dataset1.Tables("result").Rows.Count - 1
dt.Rows.Add(CreateRow("[" +
dataset1.Tables("result").Rows(intCounter).Item("f ield1").split(",")(1).subs
tring(1, 1).toupper +
dataset1.Tables("result").Rows(intCounter).Item("f ield1").split(",")(0).subs
tring(0, 1).toupper + "]:" +
dataset1.Tables("result").Rows(intCounter).Item("f ield1"),
dataset1.Tables("result").Rows(intCounter).Item("f ield2"), dt))
Next
End If
"An unhandled exception was generated during the execution of the current
web request. Information regarding the origin and location of the exception
can be identified using the exception stack trace below.

Stack Trace:

[IndexOutOfRangeException: Index was outside the bounds of the array.]
System.Array.InternalGetValue(Int32 index1, Int32 index2, Int32 index3)
+0
System.Array.GetValue(Int32 index) +32
Microsoft.VisualBasic.CompilerServices.LateBinding .LateIndexGet(Object o,
Object[] args, String[] paramnames) +187
sharedcal.ShareCal.o() +655
sharedcal.ShareCal.Page_Load(Object o, EventArgs e) +799
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750


Nov 21 '05 #1
4 3580
Hi,

Two ways it could fail with that error. 1 no comma in string split
will only create an item 0 in the array. Second the first letter in a
string is at position 0 so if the string isnt 2 characters long
substring(1,1) will fail. It is also better to use & to combine strings
than +.

Dim a() As String = "No commas here".Split(",".ToCharArray)

Debug.WriteLine(a(1)) ' Index outside of bounds error here

Ken
---------------------
"Antoine" <mf****@dsl-spam.pipex.com> wrote in message
news:10*************@corp.supernews.com...
Herfried and Cor:-

I used tracing and actually tracked down the code that was causing the
problem most likely. I wonder if you wanted to comment on it.

Also I wonder if there is a better way of testing if there is data than
testing the length of the xml string I used as stringreader to create the
dataset, but thats a side issue.

I think I tried isdbnull and is nothing and stuff like that and they cause
run time errors if there isnt any data, in other areas of code I have had
problems with using it so found this a reasonable way of ensuring the string
returned with data that must mean there was data - as I have a catch anyway
so if any errors occur, it will quit before it gets to these string length
testing parts of code.

Anyway back to the actual problem. I THINK its because the application
usually throws a comma in the field1, but I can reproduce the error if I
don't.
I THINK I either need to change my selection of fields (and get less
complicated and get data from seperate fields that might contain same data )
or test for an index of comma in the file, and do something different if
there is no comma.

If Len(xmlstr1) > 25 Then
For intCounter = 0 To dataset1.Tables("result").Rows.Count - 1
dt.Rows.Add(CreateRow("[" +
dataset1.Tables("result").Rows(intCounter).Item("f ield1").split(",")(1).subs
tring(1, 1).toupper +
dataset1.Tables("result").Rows(intCounter).Item("f ield1").split(",")(0).subs
tring(0, 1).toupper + "]:" +
dataset1.Tables("result").Rows(intCounter).Item("f ield1"),
dataset1.Tables("result").Rows(intCounter).Item("f ield2"), dt))
Next
End If
"An unhandled exception was generated during the execution of the current
web request. Information regarding the origin and location of the exception
can be identified using the exception stack trace below.

Stack Trace:

[IndexOutOfRangeException: Index was outside the bounds of the array.]
System.Array.InternalGetValue(Int32 index1, Int32 index2, Int32 index3)
+0
System.Array.GetValue(Int32 index) +32
Microsoft.VisualBasic.CompilerServices.LateBinding .LateIndexGet(Object o,
Object[] args, String[] paramnames) +187
sharedcal.ShareCal.o() +655
sharedcal.ShareCal.Page_Load(Object o, EventArgs e) +799
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750

Nov 21 '05 #2
Antoine,

In advance I think that it is for yourself not good to address these
questions to me alone (I cannot speak for Herfried).

Some things can easily be answered by me, others questions by others,
therefore it is a community, so it is better not to address questions to
special people.

When I was you I would place this question again, without that Cor and
Herfried to give yourself a better change. And than show what is that
createrow, because I don't know that as a function to create a datarow.
(However maybe others do)

Just to help nothing offended or whatever,

Cor


Nov 21 '05 #3
"Cor Ligthert" <no************@planet.nl> wrote in message
news:eU**************@TK2MSFTNGP11.phx.gbl...
Antoine,

In advance I think that it is for yourself not good to address these
questions to me alone (I cannot speak for Herfried).

Some things can easily be answered by me, others questions by others,
therefore it is a community, so it is better not to address questions to
special people.

When I was you I would place this question again, without that Cor and
Herfried to give yourself a better change. And than show what is that
createrow, because I don't know that as a function to create a datarow.
(However maybe others do)

Just to help nothing offended or whatever,

Cor


Absolutely none taken.

Thanks for you advice, I thik I understand now to redo the code anyway, and
access a completely differnent call that allows seperate fields. The one I
was doing only brought out a database "combined" field, which of course with
such combinations would just lead to complicated code.

Thanks!
Nov 21 '05 #4

Thanks I will take to heart your info particulary about using &

I thik I understand now to redo the code anyway, and access a completely
differnent call that allows seperate fields. The one I was doing only
brought out a database "combined" field, which of course with such
combinations would just lead to complicated code because of combinations of
"," white space etc etc

Thanks!

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
Hi,

Two ways it could fail with that error. 1 no comma in string split will only create an item 0 in the array. Second the first letter in a
string is at position 0 so if the string isnt 2 characters long
substring(1,1) will fail. It is also better to use & to combine strings
than +.

Dim a() As String = "No commas here".Split(",".ToCharArray)

Debug.WriteLine(a(1)) ' Index outside of bounds error here

Ken
---------------------
"Antoine" <mf****@dsl-spam.pipex.com> wrote in message
news:10*************@corp.supernews.com...
Herfried and Cor:-

I used tracing and actually tracked down the code that was causing the
problem most likely. I wonder if you wanted to comment on it.

Also I wonder if there is a better way of testing if there is data than
testing the length of the xml string I used as stringreader to create the
dataset, but thats a side issue.

I think I tried isdbnull and is nothing and stuff like that and they cause
run time errors if there isnt any data, in other areas of code I have had
problems with using it so found this a reasonable way of ensuring the string returned with data that must mean there was data - as I have a catch anyway so if any errors occur, it will quit before it gets to these string length
testing parts of code.

Anyway back to the actual problem. I THINK its because the application
usually throws a comma in the field1, but I can reproduce the error if I
don't.
I THINK I either need to change my selection of fields (and get less
complicated and get data from seperate fields that might contain same data ) or test for an index of comma in the file, and do something different if
there is no comma.

If Len(xmlstr1) > 25 Then
For intCounter = 0 To dataset1.Tables("result").Rows.Count - 1
dt.Rows.Add(CreateRow("[" +
dataset1.Tables("result").Rows(intCounter).Item("f ield1").split(",")(1).subs tring(1, 1).toupper +
dataset1.Tables("result").Rows(intCounter).Item("f ield1").split(",")(0).subs tring(0, 1).toupper + "]:" +
dataset1.Tables("result").Rows(intCounter).Item("f ield1"),
dataset1.Tables("result").Rows(intCounter).Item("f ield2"), dt))
Next
End If
"An unhandled exception was generated during the execution of the current
web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[IndexOutOfRangeException: Index was outside the bounds of the array.]
System.Array.InternalGetValue(Int32 index1, Int32 index2, Int32 index3)
+0
System.Array.GetValue(Int32 index) +32
Microsoft.VisualBasic.CompilerServices.LateBinding .LateIndexGet(Object o, Object[] args, String[] paramnames) +187
sharedcal.ShareCal.o() +655
sharedcal.ShareCal.Page_Load(Object o, EventArgs e) +799
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750


Nov 21 '05 #5

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

Similar topics

1
by: kim | last post by:
Scenario (I'm a newbie): I have a datagrid with countries listed and 5 parameters in each row. I want to add a row to this datagrid via an Event Handler. Very basic stuff. This method then call a...
0
by: Eugene | last post by:
Hello all, I've been trying to figure this out for a few days now, and still have no clue what's going on... I have a few related tables in MS Access (Clients, Cars, Sales), and a datagrid,...
2
by: David Laub | last post by:
A transform that works fine in XMLSPy fails when I run it under dot net. I've run many other transforms successfully in dot net so there is something "special" about this transform I just...
1
by: melinda | last post by:
How do you set up a MDI interface so that one of the MDI forms can be dragged outside of the parent form. For example, in Visual Studio, you can do this with some of the windows. Is this MDI? ...
0
by: Trapulo | last post by:
I've a datagrid filled with a collection of objects that inherits from basecollection. When I remove an item from this collection and then click onto the datagrid, I've always this error: ...
3
by: writebrent | last post by:
I wrote a little interface for users to post data to a website. On their local machines, it produces CSV from an Excel spreadsheet, then posts it to the site. In some cases, the CSV will contain...
15
by: bill | last post by:
I am trying to write clean code but keep having trouble deciding when to quote an array index and when not to. sometimes when I quote an array index inside of double quotes I get an error about...
5
by: Pseudonyme | last post by:
Dear All : Ever had an httpd error_log bigger than the httpd access log ? We are using Linux-Apache-Fedora-Httpd 2006 configuration. The PHP lines code that lead too tons of errors are : ...
3
by: kalaivani572 | last post by:
i am getting "Index was outside the bounds of the array." error when i try to get the checked items from list view. the code is private void btnFinish_Click(object sender, EventArgs e) {...
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...
1
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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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.