SQL Execution Results

VeRiTo
07-19-2004, 08:04 AM
:chuckle:
hi people! In MS SQL Server 8 (query analyzer) when
i execute a query (insert/update/delete) i get the message '2 rows affected'. I wonder how to know how many records have been affected when i execute the query from VB6 using Ado.
Example:


Dim CnDB as New ADODB.Connection
CnDB.Open .....

....
CnDB.Excute "UPDATE Articles SET ArtName='xName' WHERE ArtCod<100;"

Msgbox "5 Records affected!"


Thanks in advanced!!!

Dennis DVR
07-19-2004, 08:06 AM
i think execute method has a another parameter that you can pass to get the number of rows affected by the process

MKoslof
07-19-2004, 08:18 AM
:)



Dim iaffected As Long

iaffected = 0

'your insert or update statement here
strString = "INSERT INTO myTable SELECT....."

'where cn is your open, active ADO connection

cn.Execute strString, iaffected

'return the number of recs affected

If iaffected > 0 Then
MsgBox "records added: " & iaffected
End If

VeRiTo
07-19-2004, 08:25 AM
oh! thanks a lot!!! :)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum