?
Solved

insert new row into dataset from a For Next loop

Posted on 2005-03-16
2
Medium Priority
?
234 Views
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?

Thanks.
0
Comment
Question by:Sigh_Man
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
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
        Next

0
 
LVL 1

Author Comment

by:Sigh_Man
ID: 13561951
Thanks.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

764 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