Question Reorder columns in datatable (in the IDE)

Erik

New member
Joined
Sep 2, 2008
Messages
1
Programming Experience
10+
I have a datatable that is generated from a standard ad-hoc sql SELECT query. Is it possible to reorder the columns in the IDE? Dragging them does not work, changing the sql select order does not make any difference. And I have not found any way to regenerate the datatable without first deleting it and then rebuild it. (Which is not an option because you then have to delete the tableadapter, **** up relations etc...)

Any ideas?

/Erik
 
I'm not sure how reorder columns in the IDE.

When I've had a DataTable in the past that I needed to reorder I've used SetOrdinal. It's not a pretty solution but it gets the job done.

VB.NET:
dt.Columns("ColumnName").SetOrdinal(0)
dt.Columns("AnotherColumn").SetOrdinal(1)
 
I don't know what you meant by "changing the select order doesn't work"? But I can tell you that it does work. Select the columns in the select statement in the order you want.
 
Back
Top