473,387 Members | 1,698 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.

How can i Move to the Next Record?

Hi can anyone help me how can i move to the next record?

While Reader.Read
For Each Row As DataRow In Table.Rows
If Reader("UserID") = Row("UserID") Then
' I need to Move to the next Row here..
' How can i Move to the Next Row?
Else
Dim Item As New ListViewItem
Call Item.SubItems.Add(Reader("Name"))
Call Item.SubItems.Add(Reader("UserID"))
Call ListView1.Items.Add(Item)
End If
Next
End While

Thanks..
Nov 3 '07 #1
10 6891
balabaster
797 Expert 512MB
Hi can anyone help me how can i move to the next record?

While Reader.Read
For Each Row As DataRow In Table.Rows
If Reader("UserID") = Row("UserID") Then
' I need to Move to the next Row here..
' How can i Move to the Next Row?
Else
Dim Item As New ListViewItem
Call Item.SubItems.Add(Reader("Name"))
Call Item.SubItems.Add(Reader("UserID"))
Call ListView1.Items.Add(Item)
End If
Next
End While

Thanks..
Reader.Read is a method that advances the record to the next and returns a boolean. If an advance was successful, true is returned, if not, false is returned. Consequently While Reader.Read automatically advances the record on every iteration of your loop. If you need to advance the record inside your loop - add the line Reader.Read in the position you need the advance.
Nov 3 '07 #2
Thank you for the information,
My concern is I need to move the record to the next row of my table.
Nov 3 '07 #3
balabaster
797 Expert 512MB
So you basically want to continue your loop at the next iteration of your For Each Row...blah blah blah. You've already got a For Each advancing your rows...so just Continue For your loop will exit to the next iteration


Expand|Select|Wrap|Line Numbers
  1.  For Each Row As DataRow in Table.Rows 
  2.   If Row("User") = Reader("User") Then Continue For 'Jumps straight to Next
  3.  
  4.   'Do stuff not attributed to moving on to the next user
  5.  
  6. Next
  7.  
Nov 3 '07 #4
Yes that’s what I wanted to jump to the next row of my table row.
What is the code to jump straight to my next?
Nov 3 '07 #5
I’m using visual studio 2003.
Nov 3 '07 #6
I don’t think that Continue Function exist in V.S 2003
Nov 3 '07 #7
balabaster
797 Expert 512MB
I don’t think that Continue Function exist in V.S 2003
So what about using flow control to do this? You're basically saying that if your user id matches then don't do this stuff but go on to the next iteration of your loop...which could be said as: so long as your user id's don't match then do this stuff.

Pseudo code:
Expand|Select|Wrap|Line Numbers
  1. For Each Row in Rows 
  2.   If Not Row("User") = Reader("User")
  3.     'Do stuff
  4.   End If
  5. Next
  6.  
Nov 3 '07 #8
For Each Row in Rows
If Not Row("User") = Reader("User")
'Do stuff -> i need to go to the next record here that's what i wanted to do here


End If
Next
Nov 5 '07 #9
first see my first post i'm in reader loop.
Nov 5 '07 #10
balabaster
797 Expert 512MB
Hi can anyone help me how can i move to the next record?

While Reader.Read
For Each Row As DataRow In Table.Rows
If Reader("UserID") = Row("UserID") Then
' I need to Move to the next Row here..
' How can i Move to the Next Row?
Else
Dim Item As New ListViewItem
Call Item.SubItems.Add(Reader("Name"))
Call Item.SubItems.Add(Reader("UserID"))
Call ListView1.Items.Add(Item)
End If
Next
End While

Thanks..
Okay, obviously I need to spell it out from scratch:

First of all Reader is not a loop and neither is Reader.Read...While is the loop. Reader.Read is just an instruction that tells the datareader to read the next row of the recordset. The method "Read" returns a boolean value indicating that the reader successfully read the next row. If you want to advance to the next reader record you just use Reader.Read like so:

Expand|Select|Wrap|Line Numbers
  1. While Reader.Read 
  2. For Each Row As DataRow In Table.Rows
  3.     If Reader("UserID") = Row("UserID") Then
  4.      'If you just want to skip to the next reader record and continue on 
  5.      'then do the following:
  6.      Reader.Read 
  7.      'Or if you want to skip the rest of the For loop and go on to the
  8.      'the next iteration of your While loop then do the following:
  9.      Exit For
  10.     Else
  11.      Dim Item As New ListViewItem
  12.      Call Item.SubItems.Add(Reader("Name"))
  13.      Call Item.SubItems.Add(Reader("UserID"))
  14.      Call ListView1.Items.Add(Item)
  15.     End If
  16. Next
  17. End While
I already stated that this is what you had to do in my first response. I don't think I can explain it any clearer than that. Good luck.
Nov 5 '07 #11

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

Similar topics

8
by: Hung Huynh | last post by:
Hi, I'm trying to use either one of these methods to position the cursor in a specific position inside a recordset, but neither one seems to work. For example, I have 10 records in my rsData...
6
by: (Pete Cresswell) | last post by:
I *know* I've seen this before but can't remember where. Got a subform - pretty simple, actually. It's lined to a work table that contains comments related to a mutual fund. No problem...
2
by: Anand Ganesh | last post by:
Hi All, How to Implement Move Next, Move Previous, Last Record and First Record in a DataGrid Control ? Is there any standard tool available in the tool box button? Thanks for your time. ...
3
by: dianaj86 | last post by:
I have multiple dropdownlists each one filled with values from a specific column in the table. Also I have multiple textboxes corresponding to dropdownlists. For example, when I select an item from...
6
by: Neekos | last post by:
ok i have the following snippet of code. All i want it to do is move to the next record, but i keep getting an error of: You cannot go to the specified record. amount = DCount("*", "") counter =...
8
by: jmarcrum | last post by:
I have a table with about 100 records. The user has the ability to click a button on the main form that will open up a "move to the next year" form. A query displays all 100 records on the...
4
by: pgcn | last post by:
Hi Using A2003 My db has main form with stakeholderID & other main details. When there are a number of detail subform records it often requires two clicks of the next/previous nav buttons...
3
by: Lynx101 | last post by:
I am trying to move a subform onto the next record with: DoCmd.GoToRecord acForm, "MaintainAssets_edit", acNext but when I do this I get "The object 'MaintainAssets_edit' is isn't open". I...
2
by: mfaisalwarraich | last post by:
hi everybody, im new to vb.net and have googled around for moving to next record. i connected a MS Access Database using data source in Visual Studio 2008. im using the following code. ...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.