Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What does SQLEXEC() return after an UPDATE... command?
Message
From
16/10/2004 15:16:47
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00951936
Message ID:
00951982
Views:
8
Hi Fabio,

It's good to see that there is a way with SQL Server.

I am using VFP ODBC driver though and I *assume* that it does not support @@rowcount. _Tally also does not seem to apply.

I've gotta redesign the application for this part. At least I have the list (Listbox) of updated records so I can use that to pre-verify.

Thanks

>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)
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform