ou need to create an ADO Data Control first... See the doc below taken from
Visual C++ 6 online help (Using ADO Databinding in Visual C++). I started
off using the DBGrid control but I now prefer to populate a CListCtrl
manually from a CRecordset because you get a lot more control. It's not as
hard as it sounds either - just read up on CDatabase and CRecordset and it
will soon make sense. If you are really stuck I will provide some sample
code.
Hope this helps,
Clive.
=========================================================
Using ADO Databinding in Visual C++
Using ADO databinding in Visual C++ requires the following steps.
a.. Add an ADO Data Control.
b.. Point to a data source.
c.. Specify the record source (SQL query or data retrieval language).
d.. Add an ADO data-bound control.
e.. Connect the data-bound control to an ADO Data Control.
f.. Select the fields to bind to the ADO Data Control's record source.
To use ADO databinding in Visual C++
1.. Create an MFC Dialog application or MFC Formview application using the
MFC AppWizard.
2.. Add the Microsoft ADO Data Control to the dialog box; see Inserting
the Control into a Visual C++ Application.
3.. Point the ADO Data Control to your OLE DB data source.
1.. Right-click on the ADO Data Control and select Properties from the
shortcut menu.
2.. On the Control tab, select the Use Connection String. You can use
the supplied provider or you can delete it.
3.. Select Build. If you deleted the provider from Use Connection
String, you will now be able to define one. After you define the provider,
access the properties of the ADO Data Control again and select Build again
to continue.
If a provider is defined in Use Connection String before you select
Build, you will now be able to define the data link properties. This
displays the DataLink Wizard.
4.. Change the Provider if necessary, and define Location and Data
Source values, as appropriate for your provider. For example, if you are
using a SQL Server provider, Location specifies the database server and Data
Source specifies the database. If you are using an ODBC provider, the Data
Source corresponds to the ODBC DSN.
5.. Select the Authentication tab and set values for User Name and
Password, if required by the data source.
6.. Return to the Connection tab and click Test Connection to test the
data source. Scroll to the end of the Results window to see if the test
passed. If it failed, check the configuration of your data source. Common
errors include invalid passwords and incorrect values for the Location and
Data Source fields.
7.. Exit the DataLink Wizard and return to the property sheet for the
ADO Data Control.
4.. In the RecordSource tab, enter a query into the Command Text (SQL).
The data-bound controls can bind to the results of this query. The query
will usually be SQL. However, some OLE DB providers do not use SQL.
5.. Set any other ADO Data Control properties as needed and close the
property sheet for the ADO Data Control.
6.. Add a data-bound control. For example, add the DataGrid control. (Do
not confuse the DataGrid control with the RDO DBGrid control.)
7.. Set the DataGrid's properties.
1.. Right-click on the DataGrid and select Properties from the shortcut
menu.
2.. Select the All tab and set the DataSource property to the ADO D