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



The information in this article applies to:

  • Microsoft ODBC Driver for SQL Server 3.7
  • Microsoft Data Access Components 2.5
  • Microsoft Data Access Components 2.6
  • Microsoft Data Access Components 2.7

This article was previously published under Q247758

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.

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.

Modification Type:MajorLast Reviewed:12/5/2003
Keywords:kbinfo KB247758