0

The CurrentCultureIgnoreCase operative worked fine on the SQL Server instance. It however isn't working on the DB2 instance I have of the same application.

I have tried the following ones:

Working (although concerned about performance hit):

s.POSTCODE.Trim().ToLower() == q.Trim().ToLower();

Not Working:

s.POSTCODE.Trim().Equals(q, StringComparison.OrdinalIgnoreCase);

Not Working:

s.POSTCODE.Trim().Equals(q, StringComparison.CurrentCultureIgnoreCase);

Any suggestions?

Thanks.

Darin Dimitrov
  • 994,864
  • 265
  • 3,241
  • 2,902
stats101
  • 1,787
  • 7
  • 31
  • 49

2 Answers2

0

Use string.Equals()

So: string.Equals(s.POSTCODE.Trim(), q.Trim(), StringComparison.CurrentCultureIgnoreCase);

Hope it helps!

CallumVass
  • 10,978
  • 26
  • 79
  • 148
  • Get the following error: Incorrect number of arguments supplied for call to method 'Boolean Equals(System.String, System.String, System.StringComparison)' – stats101 May 23 '12 at 11:54
  • Using: var res = from s in db.ADDRESS where string.Equals(s.POSTCODE.Trim(), q.Trim(), StringComparison.CurrentCultureIgnoreCase) select s; – stats101 May 23 '12 at 11:54
  • Ahh you're using it like that, I dont believe that is possible, maybe try Linq? `var res = dbContext.Address.Where(x=> string.Equals(x.POSTCODE.Trim(), q.Trim(), StringComparison.CurrentCultureIgnoreCase));` – CallumVass May 23 '12 at 12:12
  • hmm.. maybe see here: http://stackoverflow.com/questions/5080727/string-equals-not-working-as-intended But I just tried the code I posted in my comment and it worked fine :S – CallumVass May 23 '12 at 13:06
  • I on the main post that all the comparison attempts are working fine on the SQL Server database, but not on the IBM DB2 database. Think it's a bug. :S – stats101 May 23 '12 at 13:44
0

For whatever reason, the only string comparison denomination that works on DB2 is:

s.POSTCODE.Trim().ToLower() == q.Trim().ToLower();

Have tried various alternate forms with no luck.

stats101
  • 1,787
  • 7
  • 31
  • 49