in my db i have values as True/False/false/true.... i need to get only the Distinct Values as True and False and not the all values as True & False & false & true...
my c开发者_运维技巧ode:
DataTable dv= dt.DefaultView.ToTable(true, col.header);
dv.Casesensitive=true;
but i got the values as True & False & false.
how to avoid both similar values even if they as caps / small letters and to get only True & False values.
it should be done only at the backend. in C# not through query......
Or, you could just return a distinct list (assuming case insensitive db collation):
SELECT DISTINCT YourField FROM YourTable
With LINQ you can do something like this:
var s = (from p in dv
orderby p.YourColumn
select p.YourColumn.ToUpper()).Distinct();
Here is a good blog post for you.
Try setting the case of the values when selecting. Some thing like SELECT ... upper(bool_column_name) ... FROM ...
Also, check this out.
Case sensitivity affects search results, it does not affect how items are displayed.
You need to convert the values to upper case, either in the SQL statement that you use to get the data, your view or in code.
精彩评论