Solved

How Do I reorder dataTable columns

Posted on 2007-03-23
3
786 Views
1 Endorsement
Last Modified: 2012-06-27
I have a populated DataTable with a number of columns. The dataTable is filled with data from a database.
My question is how do I reorder those columns because I would like to import the data to a CVS file. In the CVS file I would like to arrange the columns in a particular order. I want the answer in VB.NET 2003.
1
Comment
Question by:LukeSayaw
3 Comments
 
LVL 21

Accepted Solution

by:
theGhost_k8 earned 250 total points
ID: 18784374

   // Get the DefaultViewManager of a DataTable.
   DataView myDataView = DataTable1.DefaultView;
   // By default, the first column sorted ascending.
   myDataView.Sort = "State, ZipCode DESC";
0
 
LVL 34

Assisted Solution

by:Sancler
Sancler earned 250 total points
ID: 18785496
Why don't you collect them from the database in the order you want to output them to CSV?  E.g.

   SELECT Field5, Field1, Field2 ... FROM myTable

instead of

   SELECT * FROM myTable

or

   SELECT Field1, Field2 ... Field5 FROM myTable

Roger
0
 

Author Comment

by:LukeSayaw
ID: 18786748
Thank you both of you for the solutions provided. But I do not think that the provided solutions will solve the problem. I will probably get back to you with more detailed explanation of the problem when I get back to work.

Catch u later
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

838 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