Microsoft KB Archive/194517

= How To Use Creatable ADO Recordsets in Visual FoxPro =

Article ID: 194517

Article Last Modified on 7/13/2004

-

APPLIES TO


 * Microsoft Visual FoxPro 6.0 Professional Edition
 * Microsoft Data Access Components 2.1 Service Pack 2
 * Microsoft Data Access Components 2.6

-



This article was previously published under Q194517



SUMMARY
Often, you find a need for temporary storage for data. ADO 2.x enables you to create recordsets on the fly for this purpose.



MORE INFORMATION
The following example creates an ADO recordset with an integer, varchar and date field, adds two records to it, and displays the contents of all fields in the recordset on the desktop: * Demonstrates creating a temporary recordset in ADO * Program creates a recordset, adds an integer, varchar * and date field, adds two records, and displays the * contents of all fields on the desktop

#DEFINE ADUSECLIENT 3 #DEFINE ADLOCKBATCHOPTIMISTIC 4 #DEFINE ADINTEGER 3 #DEFINE ADVARCHAR 200 #DEFINE ADDATE 7 #DEFINE ADFLDISNULLABLE 0x00000020 #DEFINE ADOPENSTATIC  3

oRecordSet = CREATEOBJECT("ADODB.Recordset")

WITH oRecordSet * specify client-side cursors .CURSORLOCATION = ADUSECLIENT

* add 3 fields .FIELDS.APPEND ("Key", ADINTEGER) .FIELDS.APPEND ("Data1", ADVARCHAR, 40, ADFLDISNULLABLE) .FIELDS.APPEND ("Data2", ADDATE)

* open the recordset .OPEN(,,ADOPENSTATIC, ADLOCKBATCHOPTIMISTIC)

* add a couple of records .ADDNEW .FIELDS("Key").VALUE = 1 .FIELDS("Data1").VALUE = "String1" .FIELDS("Data2").VALUE = DATE

.ADDNEW .FIELDS("Key").VALUE = 2 .FIELDS("Data1").VALUE = "Another string" .FIELDS("Data2").VALUE = {^1992/01/06} ENDWITH

* read the records back oRecordSet.Movefirst DO WHILE ! oRecordSet.EOF ? oRecordSet.FIELDS("Key").VALUE, ; oRecordSet.FIELDS("Data1").VALUE, ; oRecordSet.FIELDS("Data2").VALUE oRecordSet.MoveNext ENDDO

Additional query words: kbVFP600 kbDatabase kbActiveX

Keywords: kbhowto kbdatabase KB194517

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.