Many Windows functions let you specify a buffer size of 0 and the returned length is the size of the returned data. The following pattern is common for Windows programmers: int iSize = 0; BYTE * ...
Call SQLFetch or SQLFetchScroll to get a rowset. If bound columns are used, use the data values and data lengths now available in the bound column buffers for the rowset. If unbound columns are used, ...