Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to pass data from one object to another
Message
From
05/12/2001 16:07:21
 
 
To
04/12/2001 19:08:20
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00589517
Message ID:
00590172
Views:
40
Thanks for the code. I'll look through it and see if it helps me figure this out.

Thanks,

Michelle

>This code should help get you started. It could be in a method called Cursor2ADO of some formatter object < s >.
>
>The include file is public domain. I think it was originally posted by Ken Levy.
>
>
>#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			
>
>
>HTH
Previous
Reply
Map
View

Click here to load this message in the networking platform