469,592 Members | 1,889 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,592 developers. It's quick & easy.

Sorting and Searching Question - and the '-' character.

I am implementing an 'incremental search', where as the user types into a
textbox, a datagridview's current position is updated to match the first
record that contains what the user has typed so far. In this particular
case, I am searching the 'CompanyName' column of the underlying dataview,
which of course is sorted by this column. I have noticed that company names
like "U-Freight" and "U-Haul" appear after company names like "UBS" and "UC
Surgeons" instead of before a company name like "U.S. Steel". But when I am
searching and compare "U-" to "U.S. Steel", it says that the later is the
greater! It appears the '-' is ignored when the sort is done. Is there a
way to change this behavior?
TIA,
--
Terry
Jul 15 '07 #1
2 1305
=?Utf-8?B?VGVycnk=?= <Te***@nospam.nospamwrote in
news:9F**********************************@microsof t.com:
My guess is it has something to do with 'culture'. But it seems to me
that the default behavior for sorting a dataview should be the same as
how SQL server would sort it.
Well not really. A dataview is an in memory representation of data. .NET
could have different rules than the collation sequence on the server.
SQL Server Collation explanation:

http://msdn2.microsoft.com/en-us/lib...3(SQL.80).aspx
Jul 16 '07 #2
Yes, but the collation it is using should be the same as the one that the
string.compare function uses, by default - should it not? And the '-' is
treated like it does not exist in the sort. For example:
AB
A-C
AD
AE
A-F
etc.
So, how do I tell it to stop ignoring the '-'?

--
Terry
"Spam Catcher" wrote:
=?Utf-8?B?VGVycnk=?= <Te***@nospam.nospamwrote in
news:9F**********************************@microsof t.com:
My guess is it has something to do with 'culture'. But it seems to me
that the default behavior for sorting a dataview should be the same as
how SQL server would sort it.

Well not really. A dataview is an in memory representation of data. .NET
could have different rules than the collation sequence on the server.
SQL Server Collation explanation:

http://msdn2.microsoft.com/en-us/lib...3(SQL.80).aspx
Jul 16 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Federico G. Babelis | last post: by
22 posts views Thread by mike | last post: by
19 posts views Thread by Owen T. Soroke | last post: by
6 posts views Thread by Dennis Gearon | last post: by
4 posts views Thread by Kuku | last post: by
9 posts views Thread by Dylan Parry | last post: by
5 posts views Thread by lemlimlee | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.