Tuesday, August 23, 2011

Bug in ADODB.Command Parameters

Great, I found a bug in Microsoft's ADODB.Command parameters object, and I was unable to find any information on it anywhere on the interweb. The error message is "Incorrect Syntax near the keyword 'default'". On the surface, this is the SQL parsing engine complaining about the SQL using the reserved keyword 'default'.

It gets interesting when the SQL statement doesn't have the word 'default' in it. So what is causing the error message? It's actually an issue with the ADODB.Parameter. when a new ADODB.Parameter is created, the default value for the parameter appears to be DEFAULT. On top of that, if the ADODB.Parameter value is set to an empty string (''), then the value is changed internally to DEFAULT. In either case, ADODB is replacing the parameter placeholder with DEFAULT in the SQL statement, which fails parsing on SQL Server.

That's a really stupid bug, as an empty string is data. I want to be able to pass an empty string sometimes, as a empty string is not null or a space. What the heck Microsoft?