DataTable.Select changes order of data

  • Thread starter Thread starter tshad
  • Start date Start date
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
 
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
 
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
 
See the thread "datatable select order" under the dotnet.framework newsgroup
for the solution to this problem. Especially Wen's post.

Marc
 
Back
Top