Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 247758 - Last Review: December 5, 2003 - Revision: 4.1
INFO: No Padding of Parameters Done by SQL Driver Prior to Version 3.7x
This article was previously published under Q247758
SQLBindParameter() in the SQL Server ODBC driver version 3.7x behave differently from previous releases of the driver. With SQL Server ODBC drivers prior to version 3.7x, parameter values specified with SQLBindParameter() are not padded with spaces even when the SQL data type is SQL_CHAR.
Behavior of SQL Server ODBC driver version 3.7.x
SQLBindParameter() with SQL data type of "SQL_CHAR"
When you bind a parameter with SQLBindParameter() and the column size specified is greater than the actual length of the parameter value, the value is padded with spaces if the SQL data type is SQL_CHAR.
This causes a query like "select * from table1 where field1 like 'F%' " to return "No Data Found" even though there are matching values in the table. This is because the LIKE clause value is padded with as many spaces to match the column size specified.
SQLBindParameter() with SQL data type of "SQL_VARCHAR"
No padding is done as expected and correct results are obtained.
Behavior of older drivers (prior to 3.7x)
No padding is done in either case (SQL_CHAR or SQL_VARCHAR). So, the earlier query example gives the matching results irrespective of SQL data type being SQL_CHAR or SQL_VARCHAR with SQL Server ODBC driver version 3.6x and lower.
APPLIES TO
- Microsoft ODBC Driver for Microsoft SQL Server 3.7
- Microsoft Data Access Components 2.5
- Microsoft Data Access Components 2.6
- Microsoft Data Access Components 2.7
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate