473,386 Members | 1,674 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,386 software developers and data experts.

Baffled by dataset error....

Hi,
Can anyone offer an explanation please? (Code below).

I have a VB2005 express program that reads through a dataset (approx 100 records) looking at items 7 and 8.
If item 7 has a particular value ("R"), then I wish to delete the record.
A filter 'srsshow' is turned on to activate the feature.

When the filter is activated, this always returns the error - 'There is no row at position 9'.
However if the line with the remove statement is disabled, the loop runs right through the file without a problem, indicating that this is the line that is causing trouble. Also, the last 'debug.writeline ' before the error message returns "line 8".

What is the problem?
Why does the 'debug.writeline' not show "9" as it is executed before the line causing the error?

Many thanks.
Phil

Expand|Select|Wrap|Line Numbers
  1. For x = 0 To mdrows - 1
  2.  
  3. For y = 7 To 8 
  4. dataread = dt.Rows(x).Item(y)
  5.  
  6. 'discard records not required
  7.  
  8. If y = 7 And srshow = 0 And dataread = "R" Then skiprec = 1
  9. Next y
  10.  
  11. Debug.WriteLine("line " & x )
  12. If skiprec = 1 Then dt.Rows.Remove(dt.Rows(x))
  13. skiprec = 0
  14. y = 7 
  15. Next x
Feb 25 '07 #1
5 1742
willakawill
1,646 1GB
Hi. Looks like you have a problem with the number of rows that are left after you remove one. You may have to recount or reset after you delete a row in order to continue with the loop
Feb 25 '07 #2
Killer42
8,435 Expert 8TB
Ok, I'm not familiar with the dataset manipulation code you're using, so don't take me too seriously - I'm just curious. In this code...
Expand|Select|Wrap|Line Numbers
  1. dt.Rows.Remove(dt.Rows(x))
I would have expected to see a simple row number as the parameter, rather than an actual row object. In other words, how come it isn't simply...
Expand|Select|Wrap|Line Numbers
  1. dt.Rows.Remove(x)
Or have I just got the syntax wrong?
Feb 25 '07 #3
Ok, I'm not familiar with the dataset manipulation code you're using, so don't take me too seriously - I'm just curious. In this code...
Expand|Select|Wrap|Line Numbers
  1. dt.Rows.Remove(dt.Rows(x))
I would have expected to see a simple row number as the parameter, rather than an actual row object. In other words, how come it isn't simply...
Expand|Select|Wrap|Line Numbers
  1. dt.Rows.Remove(x)
Or have I just got the syntax wrong?


Hi,
Thanks for the reply.
I have tried your suggestion, but if I simply put a number in the brackets, I get a syntax error.

Phil
Feb 27 '07 #4
willakawill
1,646 1GB
Hi,
Thanks for the reply.
I have tried your suggestion, but if I simply put a number in the brackets, I get a syntax error.

Phil
And, good heavens, did you completely ignore what I said? Is my handle not cool enough? My picture too girly for you?
Feb 27 '07 #5
Killer42
8,435 Expert 8TB
And, good heavens, did you completely ignore what I said? Is my handle not cool enough? My picture too girly for you?
Who can take a mere face seriously, compared to an impressively animated orange swirl? :p

Seriously itfcphil, you should pay attention to willakawill, who is much more familiar with this area. I was just guessing, based on what the syntax looked like.
Feb 27 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Programatix | last post by:
Hi, I'm working on a project which includes WebServices and Windows Form application. The Windows Form application will call the WebServices to retrieve data from database. The data will be...
2
by: Programatix | last post by:
Hi, I'm working on a project which includes WebServices and Windows Form application. The Windows Form application will call the WebServices to retrieve data from database. The data will be...
8
by: Programatix | last post by:
Hi, I'm working on a project which includes XML WebServices and Windows Form application. The Windows Form application will call the XML WebServices to retrieve data from database. The data...
4
by: Mark Thomas | last post by:
Hi I do not understand why the following does not compile under Visual C++ 7.1. It is just a simple "Hello, World" program. // Hello World Application. Why does this fail? #include <iostream>...
1
by: Bob Skutnick | last post by:
Help.... I've created an ADO.NET dataset in Visual Studio (a web project). I build the project and then try to create a Crystal Report using the dataset. When I try to use the ADO.NET dataset...
17
by: A_PK | last post by:
I have problem databinding the DataGrid with DataView/DataSet after the filter... I create the following proceudre in order for user to filter as many as they want, but the following code is only...
1
by: J. Askey | last post by:
I am implementing a web service and thought it may be a good idea to return a more complex class (which I have called 'ServiceResponse') in order to wrap the original return value along with two...
8
by: Harry Strybos | last post by:
Visual Studio 2005 - SP1 - VB.Net on WinXP SP2 I add a typed dataset to my solution and get the following errors : Error 1 sub 'ReadXmlSerializable' cannot be declared 'Overrides' because it...
4
by: ltfcphil | last post by:
Hi, Can anyone offer an explanation please? (Code below). I have a program that reads through a dataset looking at items 7 and 8. If item 7 has a particular value ("R") then I wish to delete...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
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
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
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...

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.