Results 1 to 3 of 3

Thread: [RESOLVED] remove certain columns from datatable

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2007
    Posts
    694

    Resolved [RESOLVED] remove certain columns from datatable

    Hi,
    A datatable has several fields, i.e. field1, field2, field3, field9, field10, field88...

    string strData = "field1, field2, field3, ...";

    Question:
    looping through the columns of the datatable, I would like to remove the columns in strData.
    So the datatable ends up with the following columns:
    field9, field10, field88...

    HOw is the above done in C# please?

    Thanks

  2. #2
    PowerPoster abhijit's Avatar
    Join Date
    Jun 1999
    Location
    Chit Chat Forum.
    Posts
    3,226

    Re: remove certain columns from datatable

    Are you referring to a dataTable in C# code or a datatable in a database?

    If this is c# code, you can use the remove method:

    Code:
    dataTable.Columns.Remove("field1");
    Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
    save a blobFileStreamDataTable To Text Filemy blog

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2007
    Posts
    694

    Re: remove certain columns from datatable

    thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width