No matter how I tried I could not get a valid response from the
SQLRowCount in combination with native
SQLExec() function.
Every time I got ODBC error code
S1010 (Function sequence error). I use VFP 6, so I may expect it working properly with a newer FoxPro version.
So I decided to switch from FoxPro
SQlExec() to ODBC API function
SQLExecDirect. Immediately
SQLRowCount started to work returning number of updated records for my UPDATE statement.
Here is the code. As I mentioned in my previous posting, proper statement handle is obtained from
SQlGetProp() called with
"ODBChstmt" parameter:
#DEFINE SQL_SUCCESS 0
DECLARE SHORT SQLRowCount IN odbc32;
INTEGER StatementHandle, INTEGER @RowCountPtr
DECLARE SHORT SQLExecDirect IN odbc32;
INTEGER StmtHandle, STRING StmtText, INTEGER TextLen
LOCAL hFoxConn, hStmt, cStmt, nCount
hFoxConn = SQLConnect('foxx')
IF hFoxConn = -1
? 'Connection handle is invalid.'
RETURN
ENDIF
hStmt = SQLGetProp(hFoxConn, "ODBChstmt")
cStmt = "UPDATE products SET price=4.12 WHERE item LIKE 'IK%'"
IF SQLExecDirect(hStmt, cStmt, Len(cStmt)) = SQL_SUCCESS
nCount=0
IF SQLRowCount(hStmt, @nCount) = SQL_SUCCESS
? 'Records modified:', nCount
ELSE
? 'SQLRowCount: ODBC error'
ENDIF
ELSE
? 'SQLExecDirect: ODBC error'
ENDIF
= SQLDisconnect(hFoxConn)