473,480 Members | 1,545 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Index error makes no sense

When I run the following code

public DataView CreateLocationDataSource()
{
string locationConnect = "Provider=\"MSDAORA.1\";" + GetConnectionString() + "";
string locationSelect = "SelectDescription from Locations " +
" where Location = " + "'" + locationLabel.Text.ToUpper() + "'";

oda2 = new OleDbDataAdapter(locationSelect, locationConnect);
DataSet ds2 = new DataSet();

oda2.Fill(ds2, "Locate");
DataView Locate = ds2.Tables["Locate"].DefaultView;
return Locate;
}

public void FillLocation()
{
DataView loc = CreateLocationDataSource();
locDescLabel.Text = loc[0].Row["Description"].ToString();
}

I get the following error:

Index 0 is not non-negative and below total rows count.
Since I am using void why does this happen and how can I cahange my code to prevent it?

Thanks,

Dave
Nov 16 '05 #1
2 1621
I am confused what does "i am using void' mean?

In any case, it seems like no rows are being returned.

"Dave Bailey" <an*******@discussions.microsoft.com> wrote in message
news:AC**********************************@microsof t.com...
When I run the following code

public DataView CreateLocationDataSource()
{
string locationConnect = "Provider=\"MSDAORA.1\";" + GetConnectionString() + ""; string locationSelect = "SelectDescription from Locations " +
" where Location = " + "'" + locationLabel.Text.ToUpper() + "'";

oda2 = new OleDbDataAdapter(locationSelect, locationConnect);
DataSet ds2 = new DataSet();

oda2.Fill(ds2, "Locate");
DataView Locate = ds2.Tables["Locate"].DefaultView;
return Locate;
}

public void FillLocation()
{
DataView loc = CreateLocationDataSource();
locDescLabel.Text = loc[0].Row["Description"].ToString();
}

I get the following error:

Index 0 is not non-negative and below total rows count.
Since I am using void why does this happen and how can I cahange my code to prevent it?
Thanks,

Dave

Nov 16 '05 #2
Did you get back any rows? Asking for row 0 when there aren't any rows will
be a problem.

"Dave Bailey" <an*******@discussions.microsoft.com> wrote in message
news:AC**********************************@microsof t.com...
When I run the following code

public DataView CreateLocationDataSource()
{
string locationConnect = "Provider=\"MSDAORA.1\";" + GetConnectionString() + ""; string locationSelect = "SelectDescription from Locations " +
" where Location = " + "'" + locationLabel.Text.ToUpper() + "'";

oda2 = new OleDbDataAdapter(locationSelect, locationConnect);
DataSet ds2 = new DataSet();

oda2.Fill(ds2, "Locate");
DataView Locate = ds2.Tables["Locate"].DefaultView;
return Locate;
}

public void FillLocation()
{
DataView loc = CreateLocationDataSource();
locDescLabel.Text = loc[0].Row["Description"].ToString();
}

I get the following error:

Index 0 is not non-negative and below total rows count.
Since I am using void why does this happen and how can I cahange my code to prevent it?
Thanks,

Dave

Nov 16 '05 #3

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

Similar topics

1
5004
by: Wayno | last post by:
My php logs are coming up empty. I have done all I can think of, and all that made sense to me. Can someone take a look at my php.ini please and tell me what you think may be the problem. I...
25
4864
by: sql_server_2000_user | last post by:
Hi, I have a table with about 305 million rows, and a composite primary key that consists of an ascending int and an ascending varchar(18), which is typically of length 13. Even if all the keys...
16
3663
by: ES Kim | last post by:
"A Book on C" explains a technique to use an arbitrary array index range. int* p = malloc(sizeof(int) * 10) - 1; This way, the allocated array can be accessed with index range 1 ~ 10, not 0 ~...
26
3712
by: Craig Morrison | last post by:
I'm getting this: PHP Notice: Undefined index: D1 in /var/www/html..... From this line of code: $id_option = $_POST; Which is posted by this:
85
4219
by: Russ | last post by:
Every Python programmer gets this message occasionally: IndexError: list index out of range The message tells you where the error occurred, but it doesn't tell you what the range and the...
77
4349
by: Nick Maclaren | last post by:
Why doesn't the tuple type have an index method? It seems such a bizarre restriction that there must be some reason for it. Yes, I know it's a fairly rare requirement. Regards, Nick...
10
1523
by: ApexData | last post by:
I have a table called EMPLOYEES with the following fields: EmployeeID LastName FirstName OtherData, etc... In Table design: I set EmployeeID as the primary index. I created a MultiField...
18
5010
by: Dave | last post by:
Guys I am really stuck on this one. Any help or suggestions would be appreciated. We have a large table which seemed to just hit some kind of threshold. They query is somewhat responsive when...
122
5400
by: C.L. | last post by:
I was looking for a function or method that would return the index to the first matching element in a list. Coming from a C++ STL background, I thought it might be called "find". My first stop was...
2
6019
by: hall.jeff | last post by:
Before the inevitable response comes, let me assure you I've read through the posts from Guido about this. 7 years ago Guido clearly expressed a displeasure with allowing these methods for tuple....
0
7041
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,...
0
6908
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...
0
7044
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7084
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5337
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,...
1
4779
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...
0
4481
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2984
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
563
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.