Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
What does SQLEXEC() return after an UPDATE... command?
Message
 
À
16/10/2004 08:28:29
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00951936
Message ID:
00951981
Vues:
10
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform