Solved

How Do I reorder dataTable columns

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now