I’ve been tracking a really funky bug in my West Wind Web Store application that seems to crop up only very infrequently in my error logs. Basically the problem is that for some odd reason a field in a DataRow that indeed exists is not being found. In that previous post I mentioned that I had instituted some additional logging features – specifically making sure that I would also log the locale of the user accessing the application.


Well, 3 bug reports later I noticed that all errors occurred with a Turkish (tr) browser. So I changed my browser’s default language to Turkish and sure enough I could see the error occur. The code that causes the error is here:


public String Itemimage




            if (this.DataRow == null)

                  return this._Itemimage;


            if (this.UseColumns)

                  return (String) this.DataRow[this.ItemimageColumn];


                  return (String) this.DataRow["Itemimage"];




            if (DataRow != null)

                  this.DataRow["Itemimage"] = value;


            this._Itemimage = value;                             




Seems harmless enough and it works 99% of the time. But when I run with Turkish browser language simulation check out what I get in the debugger here:


The code fails when the fieldname is in mixed case. If I change the field to lowercase only it works fine!!! If I run the same code with most other language impersonations – no problemo. Only in Turkish (so far as I can tell).


Now I should mention that my Web app changes locale on each request to match the user’s locale so that numeric and date values display in their proper locale formats without me having to explicitly do this.


Now why is this failing? In some languages upper and lower case letter apparently have different meanings and they don’t quite refer to the same thing. I’m not familiar with the Turkish Alphabet treatment, but I seem to remember from a localization lecture a long while back that some alphabets treat upper and lower case differently.


What’s odd is that there are several other field accesses prior to this one and all of those actually work fine. However, this is the only field that starts with an I.


The code for the field values is generated so the fix in this case is easy – just re-generate the code and force all lower case characters. Nevertheless this is a very scary proposition, which is now making me think hard about using visitor language impersonation on my requests.


I’m just running through my entire app with the Turkish browser setting and since every request automatically switches locale it’s interesting to see all the places code is broken due to this particular bug. It’s not just DataRows, but also table names in DataSets – basically anything with a string based indexer has a potential problem with this code.


Learn something new every day.