Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


insert new row into dataset from a For Next loop

Posted on 2005-03-16
Medium Priority
Last Modified: 2010-05-18
VB.Net problem - datasets

I have some code which iterates through a dataset row by row, using a For...Next loop.

During that For Next loop I wish to add a new line to the dataset.  Will this cause a problem?  ie. will it mess up the For Next routine because there is a new line which wasn't there when it started the For...Next loop?

Question by:Sigh_Man

Accepted Solution

UnFiRe earned 1200 total points
ID: 13561908
Yes, this will cause a problem. To work around this problem, clone your dataTable and base your For Next loop on the cloned table. At the same time, the analyzing procidures inside the For Next loop should be based on your ORIGINAL table

        Dim clonedTable As DataTable = DataSet1.Table1.Clone
        For Each myRow As DataRow In myTable.Rows
              'do something to your original table


Author Comment

ID: 13561951

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question