Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Doug's N-Tier example with a problem
Message
De
27/07/2001 20:09:31
 
 
À
15/06/2001 13:49:04
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00520054
Message ID:
00536759
Vues:
11
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform