Darth Reed

Now that I have a place to put my quasi-technical babble over at MSDN, the space is reserved for me to spew my political bile and enjoy all things sci-fi. Heh.

Thursday, April 14, 2005

New and interesting bug in Windows Server 2003 Service Pack 1

I love stuff that breaks when M$ issues a new service pack! Well, not really. But I don't mind so much, unless the IT monkeys at the Day Job decide to become M$ QA and "test it" on our production servers (our development servers don't even have SP1 on them yet). Joy!

There is apparently a new as-yet undocumented bug caused by Windows Server 2003 Service Pack 1 in one of the Select(…) overloads for ADO.NET data tables that causes the collection to not respect the sort expression. Below is some example code which results in an unsorted collection (which screws up your iteration if you're expecting sortedness).

Using the following code on Windows Server 2003 Service Pack 1 (both Enterprise Edition and Web Edition):

DataTable navtbl = DataHelper.FetchSomeData();
DataRow[] dr = navtbl.Select( "NavigationId IS NULL AND IsActive = 1", "Sort ASC" );
for( int i = 0; i < dr.Length; i ++ )
{
Response.Write( (string)dr[i]["NavigationId"] );
Response.Write( " " );
Response.Write( (string)dr[i]["Label"] );
Response.Write( " " );
Response.Write( (string)dr[i]["Url"] );
Response.Write( " " );
Response.Write( (string)dr[i]["Sort"] );
Response.Write( "
" );
}

For the data (nonclustered PK in SQL Server 2000 on NavigationId):

NavigationId | Label | Url | Sort | IsActive
3 | Hi. | /there.aspx | 0 | 1
2 | Howdy! | /here.aspx | 1 | 1
1 | Hola. | /where.aspx | 2 | 1

The following output will be generated:

1 Hola. /where.aspx 2
2 Howdy! /here.aspx 1
3 Hi. /there.aspx 0

It's actually more fun, since ours were GUIDs, but the same principle seems to apply. The sort expression is being ignored. Only on Windows 2003. Windows XP with .NET 1.1 sp1 doesn't exhibit this behavior.

Can anybody tell me why SP1 is making changes to the .NET Framework behavior that aren't in the .NET SP1? It makes it hard to keep developers on Windows XP when it doesn't behave the same way as Server 2003...

If somebody @ M$ is paying attention, we'd be happy to share the actually code that failed -- it just wasn't worth opening a ticket with Premier Support. We just switched to a DataView and iterated therows that way to get around it.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

Links to this post:

Create a Link

<< Home