Solved

How Do I reorder dataTable columns

Posted on 2007-03-23
3
785 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

803 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