Few weeks ago I wrote about an ugly backward compatibility break in Microsoft SQL Server 2008. So how to write a clean code which works correctly on both 2005 and 2008 and deals with the sp_helpuser issue described in my previous post?
Let's assume that the original code is as follows:
The subtle side issue here is that it's not easy to determine whether a column is or is not available in SqlDataReader. You can try to read a value and catch an exception but this is just slow. However, another, not-so-obvious method has been proposed - please take a look here.
Let's just then add two auxiliary methods:
and change the original code to: