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

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 1620
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
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
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
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
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
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
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
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
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
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
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...
0
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...

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.