DOCUMENT:Q261108 21-JUL-2000 [foxpro] TITLE :HOWTO: Use ADO in VFP Interactively with the ADO Control PRODUCT :Microsoft FoxPro PROD/VER:WINDOWS:2.6,6.0 OPER/SYS: KEYWORDS:kbActiveX kbADO kbCtrl kbvfp600 kbGrpDSFox kbGrpDSMDAC kbDSupport kbCodeSnippet kbMDAC2 ====================================================================== ------------------------------------------------------------------------------- The information in this article applies to: - Microsoft Visual FoxPro for Windows, version 6.0 - Microsoft Data Access Components version 2.6 ------------------------------------------------------------------------------- SUMMARY ======= Normally, when using ActiveX Data Objects (ADO) in Visual FoxPro, code is written to make a call to an ODBC driver, which then retrieves the data. The same result can be accomplished interactively in a Visual FoxPro form by using the ADO Data control to access a table using an ODBC driver. You may display the results by using the DataGrid control. NOTE: The DataGrid control has not been tested with and is not supported by Microsoft Visual FoxPro. MORE INFORMATION ================ Even though the ADO control is not visible when the form runs, it has properties that allow the user to change the table and/or datasource interactively. These controls are shipped with Visual FoxPro 6.0. 1. Create a form, select the OLE ActiveX (Olecontrol) button from the Form Controls toolbar, and then click on the form. 2. Select the Insert Control button, and then scroll down and select Microsoft ADO Data, version 6.0. 3. After deciding which ODBC datasource and table that you want to access, go to the properties sheet of the form and change the following properties on Olecontrol1: CommandType - "2 - Table Command" ConnectionString - DSN= RecordSource - Make sure that DSN= is in front of your datasource name. 4. From the Form Controls toolbar, select the OLE ActiveX (Olecontrol) button to create a second olecontrol. After clicking on your form, select the Insert Control button and choose Microsoft DataGrid Control, version 6.0. 5. Add the following code to the Init event of the form and run the form: Thisform.Olecontrol2.DataSource = Thisform.Olecontrol1.Object After the form runs, the grid is populated with data from the table. 6. If the user wants to change the data in the DataGrid control interactively, then change the table name and/or datasource of the ADO Data control. For example, drop a Command button on the form and add the following code to the click event: Thisform.Olecontrol1.ConnectionString='DSN=