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

  • SEARCH
  • Home
  • 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 6584801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:34:57+00:00 2026-05-25T16:34:57+00:00

I have a adapter like this – var ds = new DataSet(T1); adapter.Fill(ds, Table1);

  • 0

I have a adapter like this –

var ds = new DataSet("T1");
adapter.Fill(ds, "Table1");

Now, Table1 has 3 columns – Col1, Col2, Col3

I have a Table 2 with Col1 and Col3. How can I use the above adapter to Insert records for only selected columns from Table1 into Table2 ? I tried this, but no luck.

// remove the column which is not required
ds.Tables["Table1"].Columns.Remove("Col2");

// clear the old table mappings
adapter.TableMappings.Clear();

// create new table mappings
DataTableMapping mapping = adapter.TableMappings.Add("Table2", ds.Tables["Table1"].ToString());
mapping.ColumnMappings.Add("Col1", ds.Tables["Table1"].Columns[0].ColumnName);
mapping.ColumnMappings.Add("Col3", ds.Tables["Table1"].Columns[2].ColumnName);

// fill the adapter with new Dataset
var newDs = ds.Copy();
adapter.Fill(newDs);
ds.Dispose();

// Insert records into new Table
recordsUpdated += adapter.Update(newDs , "Table2");

ERROR – Additional information: Missing the DataColumn ‘Col2’ in the DataTable ‘Table1’ for the SourceColumn ‘Col2’.

  • 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-25T16:34:58+00:00Added an answer on May 25, 2026 at 4:34 pm

    I have done this –

    a.Initialise a SqlDataAdapter with the new Table (SELECT * FROM Table2) – call it

    newAdapter
    

    Make sure you make – AcceptChangesDuringFill = false because, later,
    while enumerating rows, setting the rowstate to added will not work
    otherwise.

    b.Remove the unwanted column from the data table of Table1

    c.Update the row state of this data table to ‘Added’ like this –

    // 1st, commit all changes in the DataTable.
    dtTable1.AcceptChanges();
    
    // update the row state
    foreach (DataRow row in dtTable1.Rows)
    {
      row.SetAdded();
    }
    

    d.Finally ‘insert’ using the adapter created in Step a. like this –

    var recordsInserted = newAdapter.Update(dtTable1); // insert happens
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a array list like this: private ArrayList<Locations> Artist_Result = new ArrayList<Location>(); This
I have my config/database.yml like this: development: adapter: postgresql database: psql_dev username: postgres min_messages:
I have a ListView (with an Adapter of my own) where I'd like to
I have a ListView set with a adapter. This adapter receive a list of
I have a ListActivity which has an adapter that crashes. Here is the code
I have a listview connected to a custom array adapter. This list shows information
I'd like to make a list adapter that formats views like this: I want
Right now I have a list activity powered by a cursor adapter. I have
I have a typed dataset in my project. I would like to populate a
I have a custom listView. The main layout xml is something like this: <?xml

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.