Reading Columns Out Of Order Returns Incorrect Values (sql Server Odbc Driver)
Solution 1:
The answer is that this behviour won't be fixed in the ODBC driver.
In the late 1980s there was a performance benefit to forcing the client to only read columns out of the row buffer in order. You would ask the driver if you were allowed to read column values in any order through the the SqlGetInfo function:
SqlGetInfo(..., SQL_GD_ANY_ORDER, ...) //returns true or falseSQL_GD_ANY_COLUMN= SQLGetData can be called for any unbound column, including those before the last bound column. Note that the columns must be called in order of ascending column number unlessSQL_GD_ANY_ORDERis also returned.SQL_GD_ANY_ORDER= SQLGetData can be called for unbound columns in any order. Note that SQLGetData can be called only for columns after the last bound column unlessSQL_GD_ANY_COLUMNis also returned.
Even though computers have more than 4MB of RAM these days, the modern SQL Server ODBC driver continues to opt-in to this limitation from the Windows 3.0 era:
The SQL Server Native Client ODBC driver does not support using SQLGetData to retrieve data in random column order.
They very well could support such a thing, as 17 year old OLEDB drivers, as well as the ADO.NET SqlClient drivers do. But they don't; so the ODBC driver is brain-dead abomination unsuitable for real-world use.
You need to continue to use:
- SQLOLEDB (supported)
- SQLNCLI (deprecated)
- ADO.net SqlClient (supported)
Bonus Reading
Client Driver Support Policies
- OLE DB Support Policies: Applications should use the SQL Server OLE DB provider included with the Windows operating system.
- ADO Support Policies: ADO applications can use the SQLOLEDB OLE DB provider that is included with Windows if they do not require any of the features of SQL Server 2005 or later.
Post a Comment for "Reading Columns Out Of Order Returns Incorrect Values (sql Server Odbc Driver)"