473,602 Members | 2,764 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Index error makes no sense

When I run the following code

public DataView CreateLocationD ataSource()
{
string locationConnect = "Provider=\"MSD AORA.1\";" + GetConnectionSt ring() + "";
string locationSelect = "SelectDescript ion from Locations " +
" where Location = " + "'" + locationLabel.T ext.ToUpper() + "'";

oda2 = new OleDbDataAdapte r(locationSelec t, locationConnect );
DataSet ds2 = new DataSet();

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

public void FillLocation()
{
DataView loc = CreateLocationD ataSource();
locDescLabel.Te xt = loc[0].Row["Descriptio n"].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 1635
I am confused what does "i am using void' mean?

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

"Dave Bailey" <an*******@disc ussions.microso ft.com> wrote in message
news:AC******** *************** ***********@mic rosoft.com...
When I run the following code

public DataView CreateLocationD ataSource()
{
string locationConnect = "Provider=\"MSD AORA.1\";" + GetConnectionSt ring() + ""; string locationSelect = "SelectDescript ion from Locations " +
" where Location = " + "'" + locationLabel.T ext.ToUpper() + "'";

oda2 = new OleDbDataAdapte r(locationSelec t, locationConnect );
DataSet ds2 = new DataSet();

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

public void FillLocation()
{
DataView loc = CreateLocationD ataSource();
locDescLabel.Te xt = loc[0].Row["Descriptio n"].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*******@disc ussions.microso ft.com> wrote in message
news:AC******** *************** ***********@mic rosoft.com...
When I run the following code

public DataView CreateLocationD ataSource()
{
string locationConnect = "Provider=\"MSD AORA.1\";" + GetConnectionSt ring() + ""; string locationSelect = "SelectDescript ion from Locations " +
" where Location = " + "'" + locationLabel.T ext.ToUpper() + "'";

oda2 = new OleDbDataAdapte r(locationSelec t, locationConnect );
DataSet ds2 = new DataSet();

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

public void FillLocation()
{
DataView loc = CreateLocationD ataSource();
locDescLabel.Te xt = loc[0].Row["Descriptio n"].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
5021
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 double-checked the path to my error log. It is in /var/www/logs/php_error_log Thanks. :) -Wayne Stevenson
25
4900
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 used the full 18 characters of the varchar, it seems to me each key should be 22 bytes, so the index should be roughly 6.4GB. However, the size of the index as shown in EM is about 24GB, and this is slowing everything down considerably. Does...
16
3682
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 ~ 9. You cannot use p, of course, and the memory should be released with free(p + 1). It worked with gcc and MSVC, but I'm not sure if it makes sense to take the address before the initial element of an array. Does anyone have any definite answer?
26
3733
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
4267
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 offending index are. Why does it force you to determine that information for yourself when it could save you a step and just tell you? This seems like a "no-brainer" to me. Am I missing something?
77
4395
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 Maclaren.
10
1539
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 index using LastName, FirstName and called it idxLastFirst
18
5028
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 there are NO indexes on the table. However, when we index email the query takes forever. FACTS - The problem is very "data specific". I can not recreate the
122
5465
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 the Sequence Types page of the Library Reference (http://docs.python.org/lib/typesseq.html); it wasn't there. A search of the Library Reference's index seemed to confirm that the function did not exist. A little later I realized it might be called...
2
6025
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. Let me lay out (in a fresh way) why I think we should reconsider. 1) It's counterintuitive to exclude them: It makes very little sense why an indexable data structure wouldn't have .index() as a method. It makes even less sense to not allow...
0
7920
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
8401
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8054
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8268
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5867
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
5440
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3944
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2418
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
0
1254
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.