Sometimes Case Insensitivity is a bit Overkill

| No Comments | No TrackBacks

I’m working on a set of code that requires that I synchronize some data fields between my modern Microsoft SQL Server 2005 instance, and our ancient ADABAS-based mainframe database. There are two circumstances where I need to validate this information, the first, is when I need to validate that data has been entered into the mainframe correctly (currently, this entry is being done by hand, we’re lobbying for a programmatic method), and the second is when I need to reimport the results of a particular task that modifies the mainframe, but not my own system.

However, I ran into a fairly bizarre issue related to how C#, LINQ, and SQL Server all operate. For one particular course, a text field was set defining the title of the course as ‘Ballet’. Since the ADABAS doesn’t support lower-case characters this got entered into the mainframe as ‘BALLET’. It’s minor, and forcing the word to capital in our system shouldn’t have been a problem, so during the reimport, I allow such things to be “corrected”.

However, during the import, this particular change resulted in a LINQ Exception. It didn’t think the row had changed, and therefore threw an exception when I tried to update it.

ssData is the collection of data from the Mainframe, which I’ve queried using other tools. As I say above, this would consistently throw an exception, claiming that there were no changes to commit. Eventually, I ended up assigning this:

It’s really important to note that the Equals call requires an IgnoreCase flag. Without it, C# sees the two strings as being different, and will continue to except on this SubmitChanges call. But, I thought to myself, isn’t ‘Ballet ’ and ‘BALLET ’ different? Apparently not, at least in Microsoft SQL Server.

Execute that query in SQL Server, and you will get the value 1 in the result set. I’m going back and forth on this issue. It seems to me that this is a bug, but I’m not sure how many would agree. Any opinions?

  • StumbleUpon Toolbar Stumble It!

No TrackBacks

TrackBack URL: http://blog.foxxtrot.net/cgi-bin/mt-tb.cgi/316

Leave a comment

About this Entry

This page contains a single entry by Jeff Craig published on February 19, 2009 11:57 AM.

Upcoming YUI 3 Features: Collections was the previous entry in this blog.

Code Review Practices is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Once You Know, You Newegg

μ-updates

  • No Updates!
OpenID accepted here Learn more about OpenID
Powered by Movable Type 4.21-en