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 7857385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:02:07+00:00 2026-06-02T21:02:07+00:00

I am finding difficulties to convert a datatable to a new datatable using a

  • 0

I am finding difficulties to convert a datatable to a new datatable using a reference datatable. My question is confusing and I am not good at explaining things so I drew a picture (see below).

I have two datatables on memory and I need to create the third datatable using the second mapping table for reference. The column names are just for example and it can’t be hardcoded.

Hope someone can help me. Thanks a lot.

enter image description here

  • 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-06-02T21:02:08+00:00Added an answer on June 2, 2026 at 9:02 pm

    This may not be the most optimized code, but it seems to work … Basically make a new DataTable using the column names from the “New Columns” column of the mapping table, then for each row in the first table, step through the mapping table, storing the values of the “Old Columns” columns in the “New Columns” columns

    Protected Sub MapData()
    
        Dim table1 = New DataTable()
        Dim table2 = New DataTable()
        Dim table3 = New DataTable()
    
        With table1
            .Columns.Add("Fore Name")
            .Columns.Add("Sir Name")
            .Columns.Add("Date of Birth")
            .Columns.Add("Country")
    
            Dim newRow = .NewRow()
            newRow("Fore Name") = "AA"
            newRow("Sir Name") = "AA"
            newRow("Date of Birth") = "01.01.1999"
            newRow("Country") = "UK"
            .Rows.Add(newRow)
            ' etc
        End With
    
        With table2
            .Columns.Add("Old Columns")
            .Columns.Add("New Columns")
    
            Dim newRow = .NewRow()
            newRow("Old Columns") = "Fore Name"
            newRow("New Columns") = "First Name"
            .Rows.Add(newRow)
    
            newRow = .NewRow()
            newRow("Old Columns") = "Sir Name"
            newRow("New Columns") = "Last Name"
            .Rows.Add(newRow)
    
            newRow = .NewRow()
            newRow("Old Columns") = "Date of Birth"
            newRow("New Columns") = "DOB"
            .Rows.Add(newRow)
        End With
    
        For Each rowData As DataRow In table2.Rows
            table3.Columns.Add(rowData("New Columns"))
        Next
    
        For Each table1Data As DataRow In table1.Rows
            Dim newRow = table3.NewRow()
    
            For Each rowMap As DataRow In table2.Rows
                newRow(rowMap("New Columns")) = table1Data(rowMap("Old Columns"))
            Next
    
            table3.Rows.Add(newRow)
        Next
    
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Finding the angle between two vectors is not hard using the cosine rule .
After finding that starting a new intent might not be the right way to
Although there are some similar questions I’m having difficulties finding an answer on how
I am finding difficulties in validating the following if(personDS.person[0].IdFk!= DBNull.Value) this is the compile
I'm having difficulties finding out how to implement a 'configurable' behavior in a factory
I have some difficulties in finding the directory in which a given class lies.
I am a new visual basic learner and I already have some difficulties in
Finding it a little bit tedious migrating to the new Mysql Workbench (5.2.22) even
I've had difficulties in finding a tool to create a similar diagram, a navigation
I'm having difficulties finding clear/concise documentation on setting up ISAPI_Rewrite rules for multiple sites

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.