ODBC in C++: Need row count on SELECT query
Posted on 2007-11-21
When you prepare and execute a SQL statement, but before you fetch the results, is there any way to know how many rows there are in the result set? I need to create an array with the same number of elements.
Here's the application flow:
Execute SQL statement.
Bind columns to vars.
<-- I need the row count here so I can make an array of n elements.
The ODBC API has a function called SQLRowCount(), but MSDN says it only returns the number of rows affected by insert, update, or delete queries. It mentions nothing about select queries. I know I can read the entire result set to get the count, reset the cursor, and then read it again, but that is just inefficient.