> myDataReader = myCommand.ExecuteReader() > Dim myLastName As String = "" > Dim myCurrentName As String = "" > While myDataReader.Read > myCurrentName = myDataReader.GetString(0).Trim > myCompare = String.Compare(myLastName, > myCurrentName, True, > CultureInfo.InvariantCulture)
If you use a case insensitive compare, do you get the same errors? (your code will also give 1 error at first, unless the read name is "", you have to read 2 names up front.)
First, I know that none of the column valuess are equal to an empty string. If I compare what I got from the database to the empty string, I know that none of the rows will compare equal (and If they do, it is not an error).
Second, I believe that the compare that I used is case insensitive. The True parameter indicates that I should ignore case.
Also, the collations you specify do relate to cultures. So always comparing them to the invariant culture is nonsense. Some collations define codepages with characters not available in the invariant culture (like islandic) See hte documentation of CultureInfo.InvariantCulture.
I understand this. What I was trying to do is find out which collations gave me data that .NET invariant culture thought was sorted. In actual fact, I copied the list of supported collations from the Books On Line, and ran each of them through this process. I did read the documenation in BOL and in MSDN and made web searches and asked some of my co-workers and so on. The test program was a desparate shotgun approach. Sometimes, like this time, the shotgun approach produces an answer.
> Select Case myCompare > Case Is < 0, Is = 0 > ' this is goodness
this can be caused by case sensitivity, or by usage of a different codepage than the 'invariant culture'. If you're using the invariant culture ONLY in your .net code, you NEED to use the default collation in sqlserver as well.
In my database the default collation is SQL_Latin1_General_CP1_CI_AS. I assume that this is what you meant. The problem is that this collation sorts data slightly differently from what .NET thinks is sorted.
At this point, all that I care about is matching up the data from an external source to my internal database. The approach that I took was to sort both sets of data and walk along both streams, making comparisons. (And yes, I do know about set operations -- I use them all the time and I would have used them in this situation if there were not other factors that prevented their use.)
I must say that I was surprised that there was so little material available about the nuts and bolts of collations and sort orders. Perhaps, I should say (so as not to be mistaken for someone who is arrogant), I could not find such data. That is way I created the test program and performed tests that a more rational (or less tired) person might have skipped knowing that they were "nonsence".
FB
-------------------------------------------------------------------- Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com My .NET Blog : http://weblogs.asp.net/FBouma Microsoft MVP (C#) --------------------------------------------------------------------
=================================== This list is hosted by DevelopMentorŪ http://www.develop.com Some .NET courses you may be interested in:
NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles http://www.develop.com/courses/gaspdotnetls
View archives and manage your subscription(s) at http://discuss.develop.com
=================================== This list is hosted by DevelopMentorŪ http://www.develop.com Some .NET courses you may be interested in:
NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles http://www.develop.com/courses/gaspdotnetls
View archives and manage your subscription(s) at http://discuss.develop.com