473,387 Members | 1,573 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,387 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 1618
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...

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.