DataTable.Select changes order of data

T

tshad

If I am reading from a .csv file like so:

da = new OleDbDataAdapter("SELECT * FROM " +
Path.GetFileName(strFile),csvConnection);
da.Fill(ds);

The data comes back in the same order that it read it.

If you then filter like so:

DataRow[] drs = dt.Select("FieldName is not null");

The data will be sorted by that column.

How can I tell it to not sort it and just give me the data back in the same
order as the table?

Thanks,

Tom
 
C

Cor Ligthert[MVP]

thad,

Would it not be more conistent to tell the sort order in the defaultview
from the table that is in the ds.

ds.Table[0].DefaultView = "TheColumn";

Cor
 
T

tshad

Cor Ligthert said:
thad,

Would it not be more conistent to tell the sort order in the defaultview
from the table that is in the ds.

ds.Table[0].DefaultView = "TheColumn";

What does that do?

Thanks,

Tom
Cor




tshad said:
If I am reading from a .csv file like so:

da = new OleDbDataAdapter("SELECT * FROM " +
Path.GetFileName(strFile),csvConnection);
da.Fill(ds);

The data comes back in the same order that it read it.

If you then filter like so:

DataRow[] drs = dt.Select("FieldName is not null");

The data will be sorted by that column.

How can I tell it to not sort it and just give me the data back in the
same order as the table?

Thanks,

Tom
 
M

MarcG

See the thread "datatable select order" under the dotnet.framework newsgroup
for the solution to this problem. Especially Wen's post.

Marc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top