Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ADO and OLE DB Provider for ACCESS 2000
Message
De
21/03/2003 14:01:30
Kam Lee
SUNY-Health Science Center
Brooklyn, New York, États-Unis
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Titre:
ADO and OLE DB Provider for ACCESS 2000
Divers
Thread ID:
00768722
Message ID:
00768722
Vues:
71
Hi all,
I have the following code segment/logic working in VB6 but not in VFP6. The adoPatientRS.recordCount always returns -1 and cursortype always =1 (adOpenKeyset) whether I specified cursorType as adOpenStatic or adOpenKeyset before recordset Open method. I actually intend to use adOpenStatic to check if the returned adoPatientRS.recordCount > 0 or not. If not >0, I intend to do adoPatientRS.addnew to add a new record to the Access database, otherwise I will do an edit/update to the existing record.
It seems that I cannot rely on the recordset recordcount property.

Please HELP!!

* CursorTypeEnum
#define adOpenUnspecified -1
#define adOpenForwardOnly 0
#define adOpenKeyset 1
#define adOpenDynamic 2
#define adOpenStatic 3
* LockTypeEnum
#define adLockUnspecified -1
#define adLockReadOnly 1
#define adLockPessimistic 2
#define adLockOptimistic 3
#define adLockBatchOptimistic 4
* CursorLocationEnum
#define adUseClient 1
#define adUseServer 2
#define adUseClientBatch 3
PRIVATE adoDBC,adoPatientRS
set step on
adoDBC = CREATEOBJECT("adodb.Connection")
adoDBC.CursorLocation = adUseClient
adoDBC.Open ("Provider = 'Microsoft.Jet.OLEDB.4.0';data source='\TPT2003\DATA\TPT.MDB';Persist Security Info=False")
adoPatientRS=CREATEOBJECT("adodb.Recordset")
**lcMedrec_No="621932"
lcMedrec_No="662545"
lcSQL="Select * From patient where medrec_no like '" + lcMedrec_No+"'"
WITH adoPatientRS
.ActiveConnection = adoDBC
.Source = lcSQL
.CursorType = adOpenStatic
.LockType = adLockOptimistic
* .CursorLocation = adUseClient
.Open
EndWITH
llFound=.F.
IF adoPatientRS.RecordCount > 0
llFound=.T.
lcTarget_Sys_Patient_ID=adoPatientRS.fields("patkey").Value
... updating the existing record
ELSE
adoPatientRS.Addnew
.....
endif
adoPatientRS.Update
...
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform