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
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