SQL Execution Results

07-19-2004, 09:04 AM
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.

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, 09:06 AM
i think execute method has a another parameter that you can pass to get the number of rows affected by the process

07-19-2004, 09: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

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

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum