473,659 Members | 2,632 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(Cre ateRow("[" +
dataset1.Tables ("result").Rows (intCounter).It em("field1").sp lit(",")(1).sub s
tring(1, 1).toupper +
dataset1.Tables ("result").Rows (intCounter).It em("field1").sp lit(",")(0).sub s
tring(0, 1).toupper + "]:" +
dataset1.Tables ("result").Rows (intCounter).It em("field1"),
dataset1.Tables ("result").Rows (intCounter).It em("field2"), 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:

[IndexOutOfRange Exception: Index was outside the bounds of the array.]
System.Array.In ternalGetValue( Int32 index1, Int32 index2, Int32 index3)
+0
System.Array.Ge tValue(Int32 index) +32
Microsoft.Visua lBasic.Compiler Services.LateBi nding.LateIndex Get(Object o,
Object[] args, String[] paramnames) +187
sharedcal.Share Cal.o() +655
sharedcal.Share Cal.Page_Load(O bject o, EventArgs e) +799
System.Web.UI.C ontrol.OnLoad(E ventArgs e) +67
System.Web.UI.C ontrol.LoadRecu rsive() +35
System.Web.UI.P age.ProcessRequ estMain() +750


Nov 21 '05 #1
4 3600
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.supe rnews.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(Cre ateRow("[" +
dataset1.Tables ("result").Rows (intCounter).It em("field1").sp lit(",")(1).sub s
tring(1, 1).toupper +
dataset1.Tables ("result").Rows (intCounter).It em("field1").sp lit(",")(0).sub s
tring(0, 1).toupper + "]:" +
dataset1.Tables ("result").Rows (intCounter).It em("field1"),
dataset1.Tables ("result").Rows (intCounter).It em("field2"), 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:

[IndexOutOfRange Exception: Index was outside the bounds of the array.]
System.Array.In ternalGetValue( Int32 index1, Int32 index2, Int32 index3)
+0
System.Array.Ge tValue(Int32 index) +32
Microsoft.Visua lBasic.Compiler Services.LateBi nding.LateIndex Get(Object o,
Object[] args, String[] paramnames) +187
sharedcal.Share Cal.o() +655
sharedcal.Share Cal.Page_Load(O bject o, EventArgs e) +799
System.Web.UI.C ontrol.OnLoad(E ventArgs e) +67
System.Web.UI.C ontrol.LoadRecu rsive() +35
System.Web.UI.P age.ProcessRequ estMain() +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******** ******@TK2MSFTN GP11.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***@bellsout h.net> wrote in message
news:%2******** *******@TK2MSFT NGP11.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.supe rnews.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(Cre ateRow("[" +
dataset1.Tables ("result").Rows (intCounter).It em("field1").sp lit(",")(1).sub s tring(1, 1).toupper +
dataset1.Tables ("result").Rows (intCounter).It em("field1").sp lit(",")(0).sub s tring(0, 1).toupper + "]:" +
dataset1.Tables ("result").Rows (intCounter).It em("field1"),
dataset1.Tables ("result").Rows (intCounter).It em("field2"), 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:

[IndexOutOfRange Exception: Index was outside the bounds of the array.]
System.Array.In ternalGetValue( Int32 index1, Int32 index2, Int32 index3)
+0
System.Array.Ge tValue(Int32 index) +32
Microsoft.Visua lBasic.Compiler Services.LateBi nding.LateIndex Get(Object o, Object[] args, String[] paramnames) +187
sharedcal.Share Cal.o() +655
sharedcal.Share Cal.Page_Load(O bject o, EventArgs e) +799
System.Web.UI.C ontrol.OnLoad(E ventArgs e) +67
System.Web.UI.C ontrol.LoadRecu rsive() +35
System.Web.UI.P age.ProcessRequ estMain() +750


Nov 21 '05 #5

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

Similar topics

1
10765
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 Business method, which calls a Data method which calls an SP in MS SQL. My code compiles well, but the page throws "Index was outside the bounds of the array". I really can't figure why, take a look maybe you pros see can read between the...
0
2752
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, binded to dataview. Here's a catch - whenever I select a client, and then find a car which belongs to this client, and click on empty space in datagrid (that is in gray area below rows) - I get "Index was outside the bounds of the array" error......
2
2255
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 installed dot net framework 1.1 SP1 - but I still get the same error What makes this transform more complex than others is: 1) It uses an MSXSL extension function to evaluate Xpaths at run time 2) It uses an include to include the extension function 3)...
1
3552
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? Or how do you that in C#.net?
0
1297
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: "Index was outside the bounds of the array datagrid" I've tried this structure: Dim oldList As Business.MyBaseCollection = DirectCast(dgDetails.DataSource,
3
3157
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 ampersands. For example, abc,American & British Company,1,4.34,5 ded,Dog Eat Dog,2,6.3,5.766 The code on the site is pretty standard: it loops through an array of lines from the CSV split on line ends, and then loops through another
15
4461
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 enased whitespace (to my best memory) AT other times I get an undefined index notice as below: Notice: Undefined index: last_reminder_id in...
5
7359
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 : $http_ref= $HTTP_REFERER; $prog = $_COOKIE;
3
2087
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) { WaitCallback async = new WaitCallback(Executefeed); ThreadPool.QueueUserWorkItem(async, alParams); waitBar.ShowDialog(); }
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8341
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
7360
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6181
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4176
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4342
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2759
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1982
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1739
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.