>#INCLUDE 'include\AdoVfp.h' > >*** Get the structure of the cursor so we can create the recordset >lnFieldCnt = AFIELDS( laFields, tcCursor ) > >*** Create the recordSet >loRS = CREATEOBJECT( 'adodb.recordset' ) >WITH loRS > .CursorLocation = ADUSECLIENT > .LockType = ADLOCKOPTIMISTIC > *** Loop through the lafields array and add the field to the recordset > FOR lnFld = 1 TO lnFieldCnt > lnDataType = This.DataType2ADOconstant( laFields[ lnFld, 2 ] ) > *** If we had a general field, we don't want it in the recordset > IF NOT ISNULL( lnDataType ) > *** Get the field length or default it for memo fields > lnLength = IIF( laFields[ lnFld, 2 ] # 'M', laFields[ lnFld, 3 ], 256 ) > *** Set the field attributes (for example, whether or not nulls are allowed) > lnFieldAttributes = IIF ( laFields[ lnFld, 2 ] = 'M', ADFLDLONG + ADFLDISNULLABLE, ; > IIF( laFields[ lnFld,5 ], ADFLDFIXED + ADFLDISNULLABLE, ADFLDFIXED ) ) > *** OK, add the field to the recordset > .Fields.Append( ALLTRIM( laFields[ lnFld, 1 ] ), lnDataType, lnLength, lnFieldAttributes ) > ENDIF > ENDFOR > *** open the recordset so we can start adding data > .Open() > *** OK, Now scan the cursor and populate the RecordSet using its AddNew method > lnSelect = SELECT() > SELECT ( tcCursor ) > SCAN > .AddNew() > FOR lnFld = 1 TO lnFieldCnt > IF laFields[ lnFld, 2 ] # 'G' > lcField = ALLTRIM( laFields[ lnFld, 1 ] ) > luValue = EVAL( lcField ) > IF NOT EMPTY( luValue ) > .Fields( lcField ).Value = luValue > ELSE > IF NOT INLIST( VARTYPE( luValue ), 'T', 'D' ) > .Fields( lcField ).Value = luValue > ENDIF > ENDIF > ENDIF > ENDFOR > ENDSCAN >ENDWITH > >SELECT ( lnSelect ) >RETURN loRS >>