Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6715447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:36:56+00:00 2026-05-26T08:36:56+00:00

When my application loops through the first code block below, I get valid data

  • 0

When my application loops through the first code block below, I get valid data for all datarow fields.

    For Each dRow In dtExportAddr.Rows
        dtExportAddr.Rows.Add(dRow("MgrID"), dRow("LocationNum"), dRow("DeptNum"), dRow("AddressLinkID"), dRow("PositionID"))
    Next  

But I get an error when looping through that code block “Collection was modified; enumeration operation might not execute.”

So I am using the code block below:

        Dim rowCount As Integer = dtExportAddr.Rows.Count
        Dim index As Integer = 0
        For index = 0 To rowCount - 1
            Dim dRow As DataRow = dtExportAddr.Rows.Item(index)
            dtExportAddr.Rows.Add(dRow("MgrID"), dRow("LocationNum"), dRow("DeptNum"), dRow("AddressLinkID"), dRow("PositionID"))
        Next

However, in the second code block, I get a valid record for MgrID, but I get a blank value for the other fields.
When I look in the database, all fields in that table have valid values.

What would be causing the blank values?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:36:57+00:00Added an answer on May 26, 2026 at 8:36 am

    You are still adding rows to the same datatable as you were in the first code block, you are just enumerating through it in a different manner. You should create a new datatable to add your rows to, instead of the one you are looping through.

    If you do that, you should be able to use either method for your loop.

        Dim tempTable As New DataTable
    
        For Each dRow As DataRow In dtExportAddr.Rows
            Dim tempRow As DataRow = tempTable.NewRow(dRow("MgrID"), dRow("LocationNum"), dRow("DeptNum"), dRow("AddressLinkID"), dRow("PositionID"))
            tempTable.Rows.Add(tempRow)
        Next
    

    I am not sure that gets you nearer your goal, but I am having some trouble figuring out exactly what you are trying to accomplish when you loop through that data table.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote an application that loops through a set of records and prints two
in a ASP.NET application (MVC) I have a foreach loop that loops through a
I have an application which needs to loop through all the lines in text
In bare outlines, I've got an application which looks through the directories at startup
In a multithreaded application. I have a bunch of function that loop through a
I am currently trying to create an Android application that loops Audio from the
I have an application that writes many times to a formula/macro-laden workbook. It loops
My Situation: The data request chain of my application looks like this: (Client) ->
I am trying to loop through some controls in a Powershell / WPF application.
SOLUTION BELOW I've been looking all over the net to find a solution for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.