[freetds] SQLRowCount failing after prepare and execute

Matthew A. Davis azami at speakeasy.net
Fri Feb 13 16:11:20 EST 2004


Frediano Ziglio wrote:
> delete, insert and update have the same behavior... if you use
> SQLPrepare with sql server you are not able to get row count.

Hi Freddy77,

Can you point me to where this is documented?  I've been looking for it in the ODBC and SQL Server documentation, and haven't been able to find any hint of this limitation.  Also, it works with every ODBC driver and database we've used, including SQL Server on Windows.  And, in the freeTDS log, I
can see rows_affected being set to the correct value during DONEINPROC (entry at 13:40:26.738474 in the log available at http://www.speakeasy.org/~azami/code/prepare.log ).

The ODBC Programmer's Reference states (in SQLRowCount definition): "The cached row count value is valid until the statement handle is set back to the prepared or allocated state, the statement is reexecuted, or SQLCloseCursor is called."  If a statement is not prepared, how can it be reexecuted? 
If a statement is not prepared, how can it be "set back to the prepared... state"?

I don't mean to be argumentative, I just really want to understand the problem and how to fix or work around it.  The premise that you must use SQLExecDirect() if you want to be able to get a row count just doesn't make sense to me.  I appreciate your help.

-Matthew

-- 
Matthew A. Davis  ( mailto:azami at speakeasy.net )
http://www.speakeasy.net/~azami

 "It's not always popular upholding the Constitution,
  but it's always the right thing to do."
                     -Senator Patrick J. Leahy (D-Vt)



More information about the FreeTDS mailing list