Hi Claudio.
>I'm studying the samples of N-Tier that Doug Hennig published on CoDe Magazine... there's a problem with record deletion... the method return saying that the record was deleted, but if you look at table on database, it doesn't.
I finally figured out what was going on. RecordSet.Delete() tries to delete the record from the database immediately if RecordSet.LockType = adLockOptimistic. Since the ActiveConnection property is NULL, it fails to do anything, even (and this is the kicker) when you later set ActiveConnection to an open connection and call RecordSet.Update() (which is what the data object's Save method ultimately does).
The solution is to either use RecordSet.LockType = adLockBatchOptimistic or to add Delete methods to the business and data objects:
Business object:
lparameters toRS
local llReturn
with This
llReturn = .oData.Delete(toRS)
if not llReturn
.ErrorMessage = .oData.ErrorMessage
.ErrorOccurred = .T.
endif not llReturn
endwith
return llReturn
Data object:
lparameters toRS
with toRS
if This.OpenConnection()
.ActiveConnection = This.oConnection
.Delete()
.ActiveConnection = .NULL.
llReturn = not This.ErrorOccurred
else
llReturn = .F.
endif This.OpenConnection()
endwith
return llReturn
Doug