Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ADO and OLE DB Provider for ACCESS 2000
Message
De
22/03/2003 11:42:06
Kam Lee
SUNY-Health Science Center
Brooklyn, New York, États-Unis
 
 
À
21/03/2003 14:01:30
Kam Lee
SUNY-Health Science Center
Brooklyn, New York, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Divers
Thread ID:
00768722
Message ID:
00768919
Vues:
16
Instead of using recordcount property, I changed to test for recordSet.EOF()
condition to make sure the recordset is not empty. It seems to be reliable. Is this the approach people take when coding ADO access to remote server database using VFP as client? When using ADO, programmer does not seem to have a complete control of what kind of cursorType to be returned. It seems to be determined by the OLE DB Provider what kind of cursorType will
be returned to the ADO client depending on the situation. But strangely VFP and VB behave differently while using the same ADO PEMs in the code.
Anybody has any insight on this ?

Kam.

>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
>...
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform