?
Solved

How Do I reorder dataTable columns

Posted on 2007-03-23
3
Medium Priority
?
789 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

Interactive Way of Training for the AWS CSA Exam

An interactive way of learning that will help you visualize core concepts so that you can be more effective when taking your AWS certification exam.  Built for students by a student to help them understand the concepts that they are being taught.

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…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

743 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