Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What does SQLEXEC() return after an UPDATE... command?
Message
 
To
16/10/2004 08:28:29
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00951936
Message ID:
00951981
Views:
9
Hi Jim,

SQLEXEC() supports batchs of commands, so you can send a sequence of T-SQL statements in a single request and SQL Server will process all of them. That said, you could send your update statement and right after query the @@rowcount SQL Server global variable, which will contain the number of rows affected by the last SQL statement issued. Remember that this will happen in one single round-trip.

This dirty code shows an example against the Northwind database:
LOCAL lcStrConn  as String
LOCAL lnHandle   as Integer 
LOCAL lcSQLBatch as String 

lcStrConn = "Driver={SQL Server}; Server=(local); Database=Northwind; UID=sa; PWD=;"
lnHandle  = SQLSTRINGCONNECT(lcStrConn)

IF lnHandle < 1
  MESSAGEBOX("Could not connect to the database")
  RETURN .F.
ENDIF 

*-- The following statement will cause no updates
TEXT TO lcSQLBatch TEXTMERGE NOSHOW 
  UPDATE Customers SET CompanyName = 'Will not update' WHERE CustomerID = 'NONEXISTENT';
  SELECT @@rowcount as RowsUpdated
ENDTEXT 

SQLEXEC(lnHandle, lcSQLBatch, "curResult")

MESSAGEBOX("Rows Updated: " + TRANSFORM(curResult.RowsUpdated))

SQLDISCONNECT(lnHandle)
-----
Fabio Vazquez
http://www.fabiovazquez.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform