MS SQL, ColdFusion, and Form Naming Issues

I had a bug in one of my bits of code earlier this week discovered during migrating an application from a Sybase database to MSSQL database. The bug deals with how a Form element was named and called using Coldfusion. It appears that MSSQL is more strict than Sybase or that Coldfusion 8 no longer converts my variable names to all caps as it did with MX.

Example:
<cfinput name="Tin" type="text" />
...
<cfquery name="q" datasource="dsn">
SELECT * FROM tablename
where tin = '#FORM.tin#' << notice that tin is not capitalized as it is in the cfinput name. ...

This capitalization inconsistency causes the SQL to not return results in MSSQL but yet works fine for Sybase. It may be something in the conversion by Coldfusion and how it transforms #FORM.Tin# vs #FORM.tin#. It could also be server settings for Coldfusion differences since one cfm is stored in a test environment while the other is in production. I need to experiment further to determine real cause. But it is a good practice to always use the same case of your variables throughout your application. Javascript is particularly case sensitive.

Cup size   
Select size then click on coffee cup.
This entry was posted in Code. Bookmark the permalink.