Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ODBCs SQLRowCount() - How to use?
Message
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00810276
Message ID:
00811151
Views:
49
This message has been marked as a message which has helped to the initial question of the thread.
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

* obtaining real statement handle
hStmt = SQLGetProp(hFoxConn, "ODBChstmt")

* SQL statement to be executed
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)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform