[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

How Do I reorder dataTable columns

Posted on 2007-03-23
3
Medium Priority
?
791 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 21

Accepted Solution

by:
K V earned 750 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 750 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

650 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