General information
Title:
ADO and OLE DB Provider for ACCESS 2000
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
...
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only