473,386 Members | 1,997 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.

Looping through Dataset

I am using the code below to loop through a dataset for reporting
stats. The problem I have is when I modify a row of data, it counts
that row 3 times the next time i run the loop. I believe it has
something to do with the way datasets keep track of changes.

For Each row As DataRow In CustomerDataSet.Tables(0).Rows
Dim dtRedeemed As DateTime
Dim intLocation As Integer
If Not row("RedeemedOn") Is DBNull.Value Then
dtRedeemed = CDate(row("RedeemedOn"))
End If
If Not row("LocationID") Is DBNull.Value Then
intLocation = CStr(row("LocationID"))
End If

If intLocation = LocationID Then
iTotal += 1
If dtRedeemed.Date = Now.Date Then
iToday += 1
End If
End If
Next

May 24 '06 #1
1 1042
Be sure to call CustomerDataSet.AcceptChanges

T

Charlie Brown wrote:
I am using the code below to loop through a dataset for reporting
stats. The problem I have is when I modify a row of data, it counts
that row 3 times the next time i run the loop. I believe it has
something to do with the way datasets keep track of changes.

For Each row As DataRow In CustomerDataSet.Tables(0).Rows
Dim dtRedeemed As DateTime
Dim intLocation As Integer
If Not row("RedeemedOn") Is DBNull.Value Then
dtRedeemed = CDate(row("RedeemedOn"))
End If
If Not row("LocationID") Is DBNull.Value Then
intLocation = CStr(row("LocationID"))
End If

If intLocation = LocationID Then
iTotal += 1
If dtRedeemed.Date = Now.Date Then
iToday += 1
End If
End If
Next

May 24 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: bellefy | last post by:
Hi All, I have a fairly large table with approx 30K rows that updates every night via a cron script that automatically downloads the 2 new csv's. The problem is the files are downloaded from...
2
by: Cappy | last post by:
I am writing an XML menu structure. I have the following XML file <MenuItems> <Item> <Name>Homepa5ge</Name> <URL>/index.aspx</URL> <Alt>Return to homepage</Alt>...
6
by: Dan | last post by:
I'd like to loop through selected datagrid rows and extract specified columns from those rows. How would I do that? Thanks... Dan
5
by: Brian Conway | last post by:
I desperately need some help in coding how to have a completely ediable datagrid be able to loop through each row and insert into a database table. I am using a stored procedure in the database to...
1
by: Diva | last post by:
Hi, I have a data grid in my application. It has 20 rows and I have set the page size as 5. I have a Submit button on my form and when I click on Submit, I need to loop through the rows in the...
2
by: RCB | last post by:
I created a new Vb.NET project and used the Data Form Wizard to create a dataset and grid to view a single table from my database. Later I read an article about creating a Typed Dataset. I was...
7
by: Ken | last post by:
Hi All - I have a filtered GridView. This GridView has a check box in the first column. This check box is used to identify specific rows for delete operations. On the button click event I...
2
by: randy1200 | last post by:
My hope is that somebody has a thought on this, or can point to toward an article that's useful. I have the following: DataSet ds = new DataSet(); ds.ReadXml("MyData.xml"); Each MainTable...
3
by: Andy | last post by:
Hello, I have the following situation: Thread A is allocating a dataset, doing some low-level calculations and storing a pointer to the dataset in a std::list via push_back. Thread B should...
1
by: Sweetiecakes | last post by:
Hello Is there an example of looping through a dataset filling an array with it? Thank you
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: 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...
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
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.