Groups | Blog | Home
all groups > dotnet ado.net > july 2007 >

dotnet ado.net : How write SQL's "ISNULL(ThemeRank, 255)" instead in ADO.NET when sorting DataView?


Ronald S. Cook
7/11/2007 7:58:03 PM
In SQL, I can write:

SELECT *
FROM Product
ORDER BY ISNULL(ProductRank,255)

To return:

Alpha 1
Delta 2
Golf 3
Foxtrot 4
Charlie 5
Echo NULL
Bravo NULL


But how can I do this in ADO.NET in a DataView? Right now I just have:

view.Sort = "ThemeRank ASC";

I tried:

view.Sort = "ISNULL(ThemeRank, 255)";

but that didn't do the trick.

Any help would be greatly appreciated.

Thanks,
Ron



Sergey Poberezovskiy
7/11/2007 8:22:02 PM
Ron,

you will need to create a calculated column that is the result of your
function in order to be able to sort on it, for example:

view.Table.Columns.Add("Calculated", typeof(int), "IsNull(ThemeRank, 255)");
view.Sort = "Calculated";


[quoted text, click to view]
AddThis Social Bookmark Button