Welcome to the Axosoft Community, Sign in | Register | Help
in Search

Dan Suceava

Everything & Nothing

Update on the DataTable.Select Bug

Well, it appears that Microsoft's hotfix (891742) did not fix the bug entirely.  It seems to have fixed it when calling DataTable.Select with only the select filter parameter, but when using both a select filter and a sort paramter it still does not work.  In some cases the filtering doesn't work, in others the sorting doesn't work.

Consider the code from my previous post, but with a couple more rows of data:

   DataSet ds = new DataSet();
   DataTable dt = new DataTable();
   dt.Columns.Add("ID", typeof(int));
   dt.Columns.Add("Name", typeof(string));
   dt.Columns.Add("Exists", typeof(bool));
   ds.Tables.Add(dt);

   DataRow dr = dt.NewRow();
   dr[0] = 1;
   dr[1] = "Name 1";
   dr[2] = true;
   dt.Rows.Add(dr);

   dr = dt.NewRow();
   dr[0] = 2;
   dr[1] = "Name 2";
   dr[2] = false;
   dt.Rows.Add(dr);

   dr = dt.NewRow();
   dr[0] = 3;
   dr[1] = "Name 3";
   dr[2] = true;
   dt.Rows.Add(dr);

   dr = dt.NewRow();
   dr[0] = 4;
   dr[1] = "Name 4";
   dr[2] = false;
   dt.Rows.Add(dr);

The following call sorts properly, but does not filter (should return no rows but it returns 2):
   DataRow[] drs = ds.Tables[0].Select("((ID in (1,2,3,4))) AND ((Exists = 1)) AND (Exists = 0)", "ID DESC");

And this call filters ok, but does not sort properly:
   DataRow[] drs = ds.Tables[0].Select("(ID in (1,2,3,4)) AND (Exists = 1)", "Name DESC");

Although same call but sorting by ID works fine:
   DataRow[] drs = ds.Tables[0].Select("(ID in (1,2,3,4)) AND (Exists = 1)", "ID DESC");

Hopefully Microsoft has already fixed this, I'm waiting on a response from them.

There is another workaround we are contemplating, and that is using DataView.RowFilter and DataView.Sort.  Filtering and sorting through the view seems to work just fine.

Published Thursday, May 12, 2005 4:48 PM by Dan Suceava

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

No Comments

Leave a Comment

(required) 
(optional)
(required) 
Submit



© 2002 - 2007, Axosoft, LLC. All Rights Reserved. | Privacy
Bug Tracking | Defect Tracking Videos | Help Desk Software