Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

INFO: No Padding of Parameters Done by SQL Driver Prior to Version 3.7x


View products that this article applies to.

This article was previously published under Q247758

↑ Back to the top


Summary

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.

↑ Back to the top


More information

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.

↑ Back to the top


Keywords: KB247758, kbinfo

↑ Back to the top

Article Info
Article ID : 247758
Revision : 5
Created on : 12/5/2003
Published on : 12/5/2003
Exists online : False
Views : 418