string comparison

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Harold Hsu (haroldh_at_ingenium-tech.com)
Date: 09/23/04


Date: Thu, 23 Sep 2004 13:15:05 -0700

Hi all,

We have a piece of code that reads data from SQL Server and data from
Oracle. They are both strings. We are trying to compare the two strings
(dr(column).ToString()) for equality. When we display the string on screen,
they are the same. But when we try str1.CompareTo(str2), it returns -1. We
tried the following and they all return -1:

StrComp(str1, str2, CompareMethod.Text)
StrComp(str1, str2, CompareMethod.Binary)
String.Compare(str1, str2, true,
System.Globalization.CultureInfo.InvariantCulture)

But when we do a char by char comparision, all chars are equal.

Any suggestions on what might be the problem? I don't even know if it has
anything to do with the databases.

Thanks,
Harold



Relevant Pages

  • String1 <, <=, >, >=, String2
    ... maximum value at (int from_index = 2). ... I can do it by comparing charAtof all the three strings ... write a loop to compare the two strings char by char. ...
    (comp.lang.java.help)
  • reading data
    ... fgetl returns strings, ie it looks at a line of numbers as 80 char. ... As a result it does not let me compare numbers to characters and sort appropriately. ...
    (comp.soft-sys.matlab)
  • Re: String1 <, <=, >, >=, String2
    ... > I can do it by comparing charAtof all the three strings ... > write a loop to compare the two strings char by char. ... String implements the Comparable interface, ...
    (comp.lang.java.help)
  • Re: Calculating values of a 2d array by comparison of 2 strings
    ... if anyone has a suggestion to how I should do this. ... I have 2 strings that I want to compare. ... my $str2 = 'ATLL_Y'; ...
    (comp.lang.perl.misc)
  • Re: String constant in compare operation
    ... char* putSomethingThere(void); ... Its not 'correct' in either language, if your intention is to compare the strings. ...
    (comp.lang.c)