Hi All
Access 2002/2007
WinXpPro SP2
Does anyone know how to return the number of rows affected when doing an update?... In particular, ! want to detect whether or not an update to a boolean field actually represents a change (and to do so as part of the Update rather than re-query it) i.e..
If my SQL tries to:
Set the value to True when the Column was False, rows_affected = 1
Set the value to True but Column was already True, rows_affected = 0
and vice-versa?
I create SQL in VB and then execute it in an SQL Transaction using an ADODB Connection. I tried the code @@Rowcount method below but I got a -2147217900 error - Missing Operator in Query Expression @@Rowcount ??
I've also tried this syntax:
Where Rslt_Count is Dim'd as a Long...
but I get ERROR 3001... Arguments are of the wrong type, are out of acceptable range or are in conflict with one another..?
Thanks
Access 2002/2007
WinXpPro SP2
Does anyone know how to return the number of rows affected when doing an update?... In particular, ! want to detect whether or not an update to a boolean field actually represents a change (and to do so as part of the Update rather than re-query it) i.e..
If my SQL tries to:
Set the value to True when the Column was False, rows_affected = 1
Set the value to True but Column was already True, rows_affected = 0
and vice-versa?
I create SQL in VB and then execute it in an SQL Transaction using an ADODB Connection. I tried the code @@Rowcount method below but I got a -2147217900 error - Missing Operator in Query Expression @@Rowcount ??
Code:
Dim ADODBconn As ADODB.Connection
Dim rsRead As New ADODB.Recordset
'Set Up Connection and begin SQL Transaction
Set ADODBconn = CurrentProject.AccessConnection
ADODBconn.BeginTrans
'Build Update SQL
SQLLine = "UPDATE Addrs SET Record=True, Date_Record_Last_Updated='21/02/2011 14:07:00', Record_Last_Updated_By_Unique_No=7
WHERE Unique_No = 15"
'Execute the SQL
ADODBconn.Execute SQLLine, dbFailOnError
'Build SQL to check the update actually took place
SQLLine = "SELECT @@RowCount AS Rows_Changed FROM Addrs WHERE Record_Last_Updated_By_Unique_No=7"
'Execute 'Check' SQL
rsRead.Open SQLLine, ADODBconn, adOpenStatic, adLockReadOnly
I've also tried this syntax:
Code:
ADODBconn.Execute SQLLine, dbFailOnError
Rslt_Count = ADODBconn.RecordsAffected
Where Rslt_Count is Dim'd as a Long...
but I get ERROR 3001... Arguments are of the wrong type, are out of acceptable range or are in conflict with one another..?
Thanks
Last edited: